diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index fa9e8c05f6..b5f9b6dbc0 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -407,6 +407,9 @@ class Boss(QObject): self.set_modified() def edit_toc(self): + if current_container() is None: + return error_dialog(self.gui, _('No book opened'), _( + 'You must open a book before trying to edit the Table of Contents.'), show=True) self.add_savepoint(_('Before: Edit Table of Contents')) d = TOCEditor(title=self.current_metadata.title, parent=self.gui) if d.exec_() != d.Accepted: