diff --git a/src/mixxx.cpp b/src/mixxx.cpp index f88ce12fa20a..07bf47210769 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -217,6 +217,19 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args) mixxx::Translations::initializeTranslations( m_pSettingsManager->settings(), pApp, args.getLocale()); +#ifdef __LINUX__ + // If the desktop features a global menubar and we'll go fullscreen during + // startup, set Qt::AA_DontUseNativeMenuBar so the menubar is placed in the + // window like it's done in slotViewFullScreen(). On other desktops this + // attribute has no effect. This is a safe alternative to setNativeMenuBar() + // which can cause a crash when using menu shortcuts like Alt+F after resetting + // the menubar. See https://github.com/mixxxdj/mixxx/issues/11320 + bool fullscreenPref = m_pSettingsManager->settings()->getValue( + ConfigKey("[Config]", "StartInFullscreen")); + QApplication::setAttribute( + Qt::AA_DontUseNativeMenuBar, + args.getStartInFullscreen() || fullscreenPref); +#endif // __LINUX__ createMenuBar(); m_pMenuBar->hide(); @@ -265,13 +278,6 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { ConfigKey("[Config]", "StartInFullscreen")); if (args.getStartInFullscreen() || fullscreenPref) { showFullScreen(); -#ifdef __LINUX__ - // If the desktop features a global menubar and we go fullscreen during - // startup, move the menubar to the window like in slotViewFullScreen() - if (m_pMenuBar->isNativeMenuBar()) { - m_pMenuBar->setNativeMenuBar(false); - } -#endif } QString resourcePath = pConfig->getResourcePath(); @@ -1435,17 +1441,18 @@ void MixxxMainWindow::slotViewFullScreen(bool toggle) { if (toggle) { showFullScreen(); #ifdef __LINUX__ - // Fix for "No menu bar with ubuntu unity in full screen mode" Bug - // #885890 and Bug #1076789. Before touching anything here, please read + // Fix for "No menu bar with ubuntu unity in full screen mode" (issues + // #885890 and #1076789. Before touching anything here, please read // those bugs. + // Set this attribute instead of calling setNativeMenuBar(false), see + // https://github.com/mixxxdj/mixxx/issues/11320 + QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); createMenuBar(); connectMenuBar(); - if (m_pMenuBar->isNativeMenuBar()) { - m_pMenuBar->setNativeMenuBar(false); - } #endif } else { #ifdef __LINUX__ + QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, false); createMenuBar(); connectMenuBar(); #endif