From d791e3a9c8f6da1d35a3c4d10fd287af53b0273a Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 9 Sep 2024 17:13:07 +0000 Subject: [PATCH] qt gui: fix: qt6 segfaults on macOS if we add a menu item named "About" macOS reserves the "About" menu item name, similarly to "Preferences" (see a few lines above). The "About" keyword seems even more strictly locked down: not allowed as either a prefix or a suffix. - With Qt5, a matching menu item is simply auto-recognised as the special "About" item, - but with Qt6, it seems we explicitly have to do this dance, as directly adding a menu item with the "About" name results in a segfault... --- electrum/gui/qt/main_window.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index ec4a0240f..ee94bec3c 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -769,7 +769,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): run_hook('init_menubar_tools', self, tools_menu) help_menu = menubar.addMenu(_("&Help")) - help_menu.addAction(_("&About"), self.show_about) + if sys.platform != 'darwin': + help_menu.addAction(_("&About"), self.show_about) + else: + # macOS reserves the "About" menu item name, similarly to "Preferences" (see above). + # The "About" keyword seems even more strictly locked down: + # not allowed as either a prefix or a suffix. + about_action = QAction(self) + about_action.triggered.connect(self.show_about) + about_action.setMenuRole(QAction.MenuRole.AboutRole) # make sure OS recognizes it as "About" + help_menu.addAction(about_action) help_menu.addAction(_("&Check for updates"), self.show_update_check) help_menu.addAction(_("&Official website"), lambda: webopen("https://electrum.org")) help_menu.addSeparator()