mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Fixed deadlock on start with recent Qt versions
This commit is contained in:
parent
8b9cd84df7
commit
28079eb2df
2 changed files with 18 additions and 1 deletions
|
@ -977,6 +977,12 @@ QSharedPointer<OffscreenUi> 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;
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in a new issue