diff --git a/src/calibre/gui2/preferences/toolbar.py b/src/calibre/gui2/preferences/toolbar.py index 9512fc7d3d..fc8aed48da 100644 --- a/src/calibre/gui2/preferences/toolbar.py +++ b/src/calibre/gui2/preferences/toolbar.py @@ -80,6 +80,12 @@ class BaseModel(QAbstractListModel): ans.append(n) return ans + def has_action(self, name): + for a in self._data: + if a.name == name: + return True + return False + class AllModel(BaseModel): @@ -291,13 +297,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def commit(self): # Ensure preferences are showing in either the toolbar or # the menubar. - pref_in_toolbar = lm_in_toolbar = False - cm = self.models['toolbar'] - for x in cm[1]._data: - if x.name == 'Preferences': - pref_in_toolbar = True - if x.name == 'Location Manager': - lm_in_toolbar = True + pref_in_toolbar = self.models['toolbar'][1].has_action('Preferences') + lm_in_toolbar = self.models['toolbar-device'][1].has_action('Location Manager') if not pref_in_toolbar: self.models['menubar'][1].add(['Preferences']) if not lm_in_toolbar: