Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all
Unified · Split
| @@ -977,6 +977,12 @@ QSharedPointer<OffscreenUi> getOffscreenUI() { · 976 unmodified lines | ||
| 977 | 977 | #endif |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | +bool Application::initMenu() { | |
| 981 | + _isMenuInitialized = false; | |
| 982 | + qApp->getWindow()->menuBar(); | |
| 983 | + return true; | |
| 984 | +} | |
| 985 | + | |
| 980 | 986 | Application::Application( |
| 981 | 987 | int& argc, char** argv, |
| 982 | 988 | const QCommandLineParser& parser, |
| @@ -985,6 +991,8 @@ Application::Application( · 2 unmodified lines | ||
| 985 | 991 | ) : |
| 986 | 992 | QApplication(argc, argv), |
| 987 | 993 | _window(new MainWindow(desktop())), |
| 994 | + // Menu needs to be initialized before other initializers. Otherwise deadlock happens on qApp->getWindow()->menuBar(). | |
| 995 | + _isMenuInitialized(initMenu()), | |
| 988 | 996 | _sessionRunTimer(startupTimer), |
| 989 | 997 | #ifndef Q_OS_ANDROID |
| 990 | 998 | _logger(new FileLogger(this)), |
| @@ -1017,7 +1025,6 @@ Application::Application( · 26 unmodified lines | ||
| 1017 | 1025 | _snapshotSound(nullptr), |
| 1018 | 1026 | _sampleSound(nullptr) |
| 1019 | 1027 | { |
| 1020 | − | |
| 1021 | 1028 | auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); |
| 1022 | 1029 | setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); |
| 1023 | 1030 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); |
| @@ -4225,6 +4232,11 @@ bool Application::event(QEvent* event) { · 3201 unmodified lines | ||
| 4225 | 4232 | return false; |
| 4226 | 4233 | } |
| 4227 | 4234 | |
| 4235 | + // This helps avoid deadlock issue early during Application initialization | |
| 4236 | + if (!_isMenuInitialized) { | |
| 4237 | + return QApplication::event(event); | |
| 4238 | + } | |
| 4239 | + | |
| 4228 | 4240 | if (!Menu::getInstance()) { |
| 4229 | 4241 | return false; |
| 4230 | 4242 | } |