From cf6c4032d7bfdece3886bf7cc552b7789e424383 Mon Sep 17 00:00:00 2001 From: Peter Lama Date: Mon, 26 Mar 2018 09:20:31 -0700 Subject: [PATCH] Fix duplicate about entries in mac app menu Clearing the menu bar does not remove the actions from the app menu, but setting the action role allows Qt to take care of duplicates. --- src/Gui/CommandStd.cpp | 10 +++++++--- src/Gui/MenuManager.cpp | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index 1377d0fb00..50d5fe7b17 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -203,10 +203,14 @@ Action * StdCmdAbout::createAction(void) this->className(), sStatusTip).arg(exe)); pcAction->setWhatsThis(QLatin1String(sWhatsThis)); pcAction->setIcon(QApplication::windowIcon()); - pcAction->setShortcut(QString::fromLatin1(sAccel)); - //Prevent Qt from using AboutRole -- fixes issue #0001485 + pcAction->setShortcut(QString::fromLatin1(sAccel)); +#if QT_VERSION > 0x050000 + // Needs to have AboutRole set to avoid duplicates if adding the about action more than once on macOS + pcAction->setMenuRole(QAction::AboutRole); +#else + // With Qt 4.8, having AboutRole set causes it to disappear when readding it: issue #0001485 pcAction->setMenuRole(QAction::ApplicationSpecificRole); - +#endif return pcAction; } diff --git a/src/Gui/MenuManager.cpp b/src/Gui/MenuManager.cpp index 69bc4c82c3..fb69c77704 100644 --- a/src/Gui/MenuManager.cpp +++ b/src/Gui/MenuManager.cpp @@ -192,7 +192,7 @@ void MenuManager::setup(MenuItem* menuItems) const QMenuBar* menuBar = getMainWindow()->menuBar(); -#ifdef FC_OS_MACOSX +#if defined(FC_OS_MACOSX) && QT_VERSION >= 0x050900 // Unknown Qt macOS bug observed with Qt >= 5.9.4 causes random crashes when viewing reused top level menus. menuBar->clear(); #endif