diff --git a/src/calibre/gui2/dialogs/book_info.py b/src/calibre/gui2/dialogs/book_info.py index e085dcc3e2..cca2abb6e0 100644 --- a/src/calibre/gui2/dialogs/book_info.py +++ b/src/calibre/gui2/dialogs/book_info.py @@ -90,10 +90,15 @@ class BookInfo(QDialog, Ui_BookInfo): row = row.row() if row == self.current_row: return + info = self.view.model().get_book_info(row) + if info is None: + # Indicates books was deleted from library, or row numbers have + # changed + return + self.previous_button.setEnabled(False if row == 0 else True) self.next_button.setEnabled(False if row == self.view.model().rowCount(QModelIndex())-1 else True) self.current_row = row - info = self.view.model().get_book_info(row) self.setWindowTitle(info[_('Title')]) self.title.setText(''+info.pop(_('Title'))) comments = info.pop(_('Comments'), '') diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 0286acc782..112df3023c 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -374,6 +374,8 @@ class BooksModel(QAbstractTableModel): # {{{ if isinstance(index, int): index = self.index(index, 0) data = self.current_changed(index, None, False) + if data is None: + return data row = index.row() data[_('Title')] = self.db.title(row) au = self.db.authors(row)