Bulk metadata edit search and replace: Do not allow the user to perform the search and replace until she enters a search expression. See #1282357 (error produced during "Edit metadata in bulk" for replacing a value)

This commit is contained in:
Kovid Goyal 2014-02-20 10:15:13 +05:30
parent ab983165a4
commit 48dbfa26c9

View File

@ -794,10 +794,13 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
flags |= re.UNICODE flags |= re.UNICODE
try: try:
stext = unicode(self.search_for.text())
if not stext:
raise Exception(_('You must specify a search expression in the "Search for" field'))
if self.search_mode.currentIndex() == 0: if self.search_mode.currentIndex() == 0:
self.s_r_obj = re.compile(re.escape(unicode(self.search_for.text())), flags) self.s_r_obj = re.compile(re.escape(stext), flags)
else: else:
self.s_r_obj = re.compile(unicode(self.search_for.text()), flags) self.s_r_obj = re.compile(stext, flags)
except Exception as e: except Exception as e:
self.s_r_obj = None self.s_r_obj = None
self.s_r_error = e self.s_r_error = e