Bug #1996551: Possible bug: Similar books reassigned when grouped search renamed

Revert to the default if the field used in a similar search is removed (or renamed).
This commit is contained in:
Charles Haley 2022-11-15 12:10:53 +00:00
parent e76a124dcb
commit 0d01c12bf4
2 changed files with 16 additions and 3 deletions

View File

@ -43,7 +43,8 @@ class SimilarBooksAction(InterfaceAction):
row = idx.row()
# 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']
if match == 'match_all':
join = ' and '
@ -70,7 +71,11 @@ class SimilarBooksAction(InterfaceAction):
else:
val.add(v)
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)
if not val:
return

View File

@ -133,7 +133,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
if dex >= 0:
field.setCurrentIndex(dex)
else:
# 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)
def something_changed(self, dex):