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

This commit is contained in:
Kovid Goyal 2021-11-21 21:40:32 +05:30
parent a8ba150cb8
commit 7fe3d006d8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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)