From 49165056c9e7de4dbb7b394ac5ad9918b4f4b880 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 1 Mar 2019 15:39:06 +0200 Subject: [PATCH] Fixed a race condition that sometimes caused the main menus not to appear. When Interface starts, it first calls pauseUntilLoginDetermined(), and later resumeAfterLoginDialogActionTaken(). But on rare occasions these functions are called in the reverse order, and this caused Interface to remain in the "paused" state. Now we check for this case, and abort pauseUntilLoginDetermined() if it happens. This has only happened to me when running Interface immediately after rebuilding it (in Release mode). --- interface/src/Application.cpp | 9 +++++++++ interface/src/Application.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1efd9cc461..a6ab9c9782 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5414,6 +5414,13 @@ void Application::pauseUntilLoginDetermined() { return; } + if (_resumeAfterLoginDialogActionTakenWasCalled) { + // This happens occasionally (though not often): resumeAfterLoginDialogActionTaken() has already been called. + // We must abort this method, otherwise Interface will remain in the "Paused" state permanently. + // E.g., the menus "Edit", "View", etc. will not appear. + return; + } + auto myAvatar = getMyAvatar(); _previousAvatarTargetScale = myAvatar->getTargetScale(); _previousAvatarSkeletonModel = myAvatar->getSkeletonModelURL().toString(); @@ -5528,6 +5535,8 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("Developer")->setVisible(_developerMenuVisible); _myCamera.setMode(_previousCameraMode); cameraModeChanged(); + + _resumeAfterLoginDialogActionTakenWasCalled = true; } void Application::loadAvatarScripts(const QVector& urls) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 762ac9585a..421797d3a7 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -802,5 +802,8 @@ private: bool _showTrackedObjects { false }; bool _prevShowTrackedObjects { false }; + + // Whether resumeAfterLoginDialogActionTaken() has been called + bool _resumeAfterLoginDialogActionTakenWasCalled { false }; }; #endif // hifi_Application_h