Fix 753122: in preferences, clear a content server restriction if the saved search no longer exists.

This commit is contained in:
Charles Haley 2011-04-07 13:12:23 +01:00
parent 663bde0ffd
commit 4d27e7fa9d

View File

@ -18,6 +18,7 @@ from calibre.utils.config import ConfigProxy
from calibre.gui2 import error_dialog, config, open_url, warning_dialog, \ from calibre.gui2 import error_dialog, config, open_url, warning_dialog, \
Dispatcher, info_dialog Dispatcher, info_dialog
from calibre import as_unicode from calibre import as_unicode
from calibre.utils.icu import sort_key
class ConfigWidget(ConfigWidgetBase, Ui_Form): class ConfigWidget(ConfigWidgetBase, Ui_Form):
@ -42,8 +43,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
else self.opt_password.Password)) else self.opt_password.Password))
self.opt_password.setEchoMode(self.opt_password.Password) self.opt_password.setEchoMode(self.opt_password.Password)
restrictions = sorted(saved_searches().names(), restrictions = sorted(saved_searches().names(), key=sort_key)
cmp=lambda x,y: cmp(x.lower(), y.lower())) # verify that the current restriction still exists. If not, clear it.
csr = db.prefs.get('cs_restriction', None)
if csr and csr not in restrictions:
db.prefs.set('cs_restriction', '')
choices = [('', '')] + [(x, x) for x in restrictions] choices = [('', '')] + [(x, x) for x in restrictions]
r('cs_restriction', db.prefs, choices=choices) r('cs_restriction', db.prefs, choices=choices)