Skip to content

Commit

Permalink
Fix empty database triggering error at first start
Browse files Browse the repository at this point in the history
  • Loading branch information
BasioMeusPuga committed Mar 23, 2018
1 parent 7931f92 commit 34dcf9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lector/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,14 @@ def generate_library_tags(self):
db_library_directories = database.DatabaseFunctions(
self.parent.database_path).fetch_data(
('Path',),
'books', # This checks the directories table NOT the book one
'books', # THIS CHECKS THE BOOKS TABLE
{'Path': ''},
'LIKE')

library_directories = {
i[0]: (None, None) for i in db_library_directories}
library_directories = None
if db_library_directories:
library_directories = {
i[0]: (None, None) for i in db_library_directories}

def get_tags(all_metadata):
path = os.path.dirname(all_metadata['path'])
Expand All @@ -282,6 +284,7 @@ def get_tags(all_metadata):
return added_string.lower(), None

# Generate tags for the QStandardItemModel
# This isn't triggered for an empty view model
for i in range(self.view_model.rowCount()):
this_item = self.view_model.item(i, 0)
all_metadata = this_item.data(QtCore.Qt.UserRole + 3)
Expand Down
2 changes: 1 addition & 1 deletion lector/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def read_settings(self):
self.parent.settings['current_view'] = int(self.settings.value('currentView', 0))
self.parent.settings['main_window_headers'] = self.settings.value('tableHeaders', None)
self.parent.settings['listview_background'] = self.settings.value(
'listViewBackground', QtGui.QColor().fromRgb(76, 76, 76))
'listViewBackground', QtGui.QColor().fromRgb(33, 33, 33))
self.parent.settings['icon_theme'] = self.settings.value('iconTheme', 'DarkIcons')
self.settings.endGroup()

Expand Down

0 comments on commit 34dcf9f

Please sign in to comment.