diff --git a/src/calibre/gui2/actions/similar_books.py b/src/calibre/gui2/actions/similar_books.py index 5b82236150..e9015aa29b 100644 --- a/src/calibre/gui2/actions/similar_books.py +++ b/src/calibre/gui2/actions/similar_books.py @@ -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 diff --git a/src/calibre/gui2/preferences/search.py b/src/calibre/gui2/preferences/search.py index c270e54b78..5f4d7d94f9 100644 --- a/src/calibre/gui2/preferences/search.py +++ b/src/calibre/gui2/preferences/search.py @@ -133,7 +133,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): if dex >= 0: field.setCurrentIndex(dex) 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) def something_changed(self, dex):