2092: Problems when no database is open. Partial fix. Fix tags menu when
there is no database and stop accessing database for tags filter dropdown when there is no database.
This commit is contained in:
parent
721cfa1a1c
commit
2886583689
@ -209,12 +209,13 @@ class SidebarFilter(DbGUIElement):
|
||||
Called when the tag list needs to be rebuilt.
|
||||
"""
|
||||
self.__tag_list = []
|
||||
for handle in self.dbstate.db.get_tag_handles(sort_handles=True):
|
||||
tag = self.dbstate.db.get_tag_from_handle(handle)
|
||||
# for python3 this returns a byte object, so conversion needed
|
||||
if not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
self.__tag_list.append((tag.get_name(), handle))
|
||||
if self.dbstate.db is not None and self.dbstate.db.is_open():
|
||||
for handle in self.dbstate.db.get_tag_handles(sort_handles=True):
|
||||
tag = self.dbstate.db.get_tag_from_handle(handle)
|
||||
# for python3 this returns a byte object, so conversion needed
|
||||
if not isinstance(handle, str):
|
||||
handle = handle.decode('utf-8')
|
||||
self.__tag_list.append((tag.get_name(), handle))
|
||||
self.on_tags_changed([item[0] for item in self.__tag_list])
|
||||
|
||||
def on_tags_changed(self, tag_list):
|
||||
|
@ -113,6 +113,7 @@ class Tags(DbGUIElement):
|
||||
self.__tag_list = []
|
||||
|
||||
dbstate.connect('database-changed', self._db_changed)
|
||||
dbstate.connect('no-database', self.tag_disable)
|
||||
|
||||
self._build_tag_menu()
|
||||
|
||||
@ -128,10 +129,11 @@ class Tags(DbGUIElement):
|
||||
"""
|
||||
Remove the UI and action groups for the tag menu.
|
||||
"""
|
||||
self.uistate.uimanager.remove_ui(self.tag_id)
|
||||
self.uistate.uimanager.remove_action_group(self.tag_action)
|
||||
self.uistate.uimanager.ensure_update()
|
||||
self.tag_id = None
|
||||
if self.tag_id is not None:
|
||||
self.uistate.uimanager.remove_ui(self.tag_id)
|
||||
self.uistate.uimanager.remove_action_group(self.tag_action)
|
||||
self.uistate.uimanager.ensure_update()
|
||||
self.tag_id = None
|
||||
|
||||
def _db_changed(self, db):
|
||||
"""
|
||||
@ -181,9 +183,10 @@ class Tags(DbGUIElement):
|
||||
Called when the tag list needs to be rebuilt.
|
||||
"""
|
||||
self.__tag_list = []
|
||||
for handle in self.db.get_tag_handles(sort_handles=True):
|
||||
tag = self.db.get_tag_from_handle(handle)
|
||||
self.__tag_list.append((tag.get_name(), tag.get_handle()))
|
||||
if self.db is not None and self.db.is_open():
|
||||
for handle in self.db.get_tag_handles(sort_handles=True):
|
||||
tag = self.db.get_tag_from_handle(handle)
|
||||
self.__tag_list.append((tag.get_name(), tag.get_handle()))
|
||||
self.update_tag_menu()
|
||||
|
||||
def update_tag_menu(self):
|
||||
@ -203,7 +206,7 @@ class Tags(DbGUIElement):
|
||||
"""
|
||||
actions = []
|
||||
|
||||
if self.db is None:
|
||||
if self.db is None or not self.db.is_open():
|
||||
self.tag_ui = ''
|
||||
self.tag_action = ActionGroup(name='Tag')
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user