This commit is contained in:
Kovid Goyal 2022-11-15 17:45:42 +05:30
commit c0c53593b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 3 deletions

View File

@ -43,7 +43,8 @@ class SimilarBooksAction(InterfaceAction):
row = idx.row() row = idx.row()
# Get the parameters for this search # Get the parameters for this search
col = db.prefs['similar_' + typ + '_search_key'] key = 'similar_' + typ + '_search_key'
col = db.prefs[key]
match = db.prefs['similar_' + typ + '_match_kind'] match = db.prefs['similar_' + typ + '_match_kind']
if match == 'match_all': if match == 'match_all':
join = ' and ' join = ' and '
@ -70,7 +71,11 @@ class SimilarBooksAction(InterfaceAction):
else: else:
val.add(v) val.add(v)
else: else:
# Get the value of the requested field. Can be a list or a simple val # Get the value of the requested field. Can be a list or a simple
# val. It is possible that col no longer exists, in which case fall
# back to the default
if col not in mi:
col = db.prefs.defaults[key]
val = mi.get(col, None) val = mi.get(col, None)
if not val: if not val:
return return

View File

@ -133,7 +133,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
if dex >= 0: if dex >= 0:
field.setCurrentIndex(dex) field.setCurrentIndex(dex)
else: else:
field.setCurrentIndex(0) # The field no longer exists. Try the default
dex = field.findText(self.db.prefs.defaults[name])
if dex >= 0:
field.setCurrentIndex(dex)
else:
# The default doesn't exist! Pick the first field in the list
field.setCurrentIndex(0)
# Emit a changed signal after all the other events have been processed
QTimer.singleShot(0, self.changed_signal.emit)
field.blockSignals(False) field.blockSignals(False)
def something_changed(self, dex): def something_changed(self, dex):