From 3df98e099525540919b15ea4a8d3c842a1b489af Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 16 Aug 2023 18:51:48 +0530 Subject: [PATCH] E-book viewer: Show an error when creating a bookmark if the bookmark position is not found. See #2029521 (Epub files with non-functional bookmarks) --- src/calibre/gui2/viewer/bookmarks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/viewer/bookmarks.py b/src/calibre/gui2/viewer/bookmarks.py index bc918ada01..81146cb53a 100644 --- a/src/calibre/gui2/viewer/bookmarks.py +++ b/src/calibre/gui2/viewer/bookmarks.py @@ -10,7 +10,7 @@ from qt.core import ( QPushButton, Qt, QWidget, pyqtSignal, ) -from calibre.gui2 import choose_files, choose_save_file +from calibre.gui2 import choose_files, choose_save_file, error_dialog from calibre.gui2.dialogs.confirm_delete import confirm from calibre.gui2.gestures import GestureManager from calibre.gui2.viewer.shortcuts import get_shortcut_for @@ -367,6 +367,9 @@ class BookmarkManager(QWidget): return title = self.uniqify_bookmark_title(title) cfi = (pos_data.get('selection_bounds') or {}).get('start') or pos_data['cfi'] + if not cfi: + error_dialog(self, _('Failed to bookmark'), _('Could not calculate position in book'), show=True) + return bm = { 'title': title, 'pos_type': 'epubcfi',