From 89b7207ecf79eb26b382719fce063c85bac7cf57 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Nov 2021 07:46:02 +0530 Subject: [PATCH] Fix incorrect check for no open editor --- src/calibre/gui2/tweak_book/boss.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 1a3084ca81..a2633402a1 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -1340,15 +1340,17 @@ class Boss(QObject): try: mt = current_container().mime_map[name] except KeyError: - return error_dialog(self.gui, _('Does not exist'), _( + error_dialog(self.gui, _('Does not exist'), _( 'The file %s does not exist. If you were trying to click an item in' ' the Table of Contents, you may' ' need to refresh it by right-clicking and choosing "Refresh".') % name, show=True) + return None syntax = syntax_from_mime(name, mt) if not syntax: - return error_dialog( + error_dialog( self.gui, _('Unsupported file format'), _('Editing files of type %s is not supported') % mt, show=True) + return None editor = self.edit_file(name, syntax) return editor @@ -1356,7 +1358,7 @@ class Boss(QObject): if not name: return editor = self.open_editor_for_name(name) - if anchor and editor is not None: + if anchor and hasattr(editor, 'go_to_anchor') : if editor.go_to_anchor(anchor): self.gui.preview.pending_go_to_anchor = anchor elif show_anchor_not_found: