diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 88691c933a..5da3b5112d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -977,6 +977,12 @@ QSharedPointer getOffscreenUI() { #endif } +bool Application::initMenu() { + _isMenuInitialized = false; + qApp->getWindow()->menuBar(); + return true; +} + Application::Application( int& argc, char** argv, const QCommandLineParser& parser, @@ -985,6 +991,8 @@ Application::Application( ) : QApplication(argc, argv), _window(new MainWindow(desktop())), + // Menu needs to be initialized before other initializers. Otherwise deadlock happens on qApp->getWindow()->menuBar(). + _isMenuInitialized(initMenu()), _sessionRunTimer(startupTimer), #ifndef Q_OS_ANDROID _logger(new FileLogger(this)), @@ -1017,7 +1025,6 @@ Application::Application( _snapshotSound(nullptr), _sampleSound(nullptr) { - auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); setProperty(hifi::properties::CRASHED, _previousSessionCrashed); @@ -4225,6 +4232,11 @@ bool Application::event(QEvent* event) { return false; } + // This helps avoid deadlock issue early during Application initialization + if (!_isMenuInitialized) { + return QApplication::event(event); + } + if (!Menu::getInstance()) { return false; } diff --git a/interface/src/Application.h b/interface/src/Application.h index e8ffc802eb..fbd6ef8cae 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -562,6 +562,7 @@ private slots: private: void init(); + bool initMenu(); void pauseUntilLoginDetermined(); void resumeAfterLoginDialogActionTaken(); bool handleKeyEventForFocusedEntity(QEvent* event); @@ -626,6 +627,10 @@ private: void userKickConfirmation(const QUuid& nodeID, unsigned int banFlags = ModerationFlags::getDefaultBanFlags()); MainWindow* _window; + + // _isMenuInitialized: used to initialize menu early enough before it's needed by other + // initializers. Fixes a deadlock issue with recent Qt versions. + bool _isMenuInitialized; QElapsedTimer& _sessionRunTimer; bool _aboutToQuit { false };