Browse Source

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...
master
SomberNight 1 year ago
parent
commit
d791e3a9c8
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 9
      electrum/gui/qt/main_window.py

9
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"))
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()

Loading…
Cancel
Save