From 7fe3d006d80c14396fa1ecc1803c57d36a26631a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Nov 2021 21:40:32 +0530 Subject: [PATCH] Need to store a python reference to the menu on the action to avoid the menu being deleted in case it is not stored anywhere else --- src/calibre/gui2/pyqt6_compat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/pyqt6_compat.py b/src/calibre/gui2/pyqt6_compat.py index ca6e6d3c43..2b3f3d86c4 100644 --- a/src/calibre/gui2/pyqt6_compat.py +++ b/src/calibre/gui2/pyqt6_compat.py @@ -34,7 +34,12 @@ QMessageBox.exec_ = QMessageBox.exec # Restore ability to associate a menu with an action -QAction.setMenu = lambda self, menu: progress_indicator.set_menu_on_action(self, menu) +def set_menu(self, menu): + self.keep_menu_ref = menu + progress_indicator.set_menu_on_action(self, menu) + + +QAction.setMenu = set_menu QAction.menu = lambda self: progress_indicator.menu_for_action(self)