History

Fixed race condition during initialization of the Desktop.

The Application constructor must setup event handlers for events emitted when the Desktop is constructed *before* calling initializeUi(). Otherwise, sometimes these event handlers won't be called. When this problem happened (usually on slow machines), Interface would start but neither the Desktop nor the Login Screen would appear.

Oren Hurvitz committed 7 years ago

Commit 8e201f41 parent 8ff47651 file · +28 −28Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+28−28
@@ -1446,6 +1446,34 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1445 unmodified lines
14461446 _overlays.init(); // do this before scripts load
14471447 DependencyManager::set<ContextOverlayInterface>();
14481448
1449+ auto offscreenUi = getOffscreenUI();
1450+ connect(offscreenUi.data(), &OffscreenUi::desktopReady, []() {
1451+ // Now that we've loaded the menu and thus switched to the previous display plugin
1452+ // we can unlock the desktop repositioning code, since all the positions will be
1453+ // relative to the desktop size for this plugin
1454+ auto offscreenUi = getOffscreenUI();
1455+ auto desktop = offscreenUi->getDesktop();
1456+ if (desktop) {
1457+ desktop->setProperty("repositionLocked", false);
1458+ }
1459+ });
1460+
1461+ connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
1462+#if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML)
1463+ // Do not show login dialog if requested not to on the command line
1464+ QString hifiNoLoginCommandLineKey = QString("--").append(HIFI_NO_LOGIN_COMMAND_LINE_KEY);
1465+ int index = arguments().indexOf(hifiNoLoginCommandLineKey);
1466+ if (index != -1) {
1467+ resumeAfterLoginDialogActionTaken();
1468+ return;
1469+ }
1470+
1471+ showLoginScreen();
1472+#else
1473+ resumeAfterLoginDialogActionTaken();
1474+#endif
1475+ });
1476+
14491477 // Initialize the user interface and menu system
14501478 // Needs to happen AFTER the render engine initialization to access its configuration
14511479 initializeUi();
@@ -1791,34 +1819,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 339 unmodified lines
17911819
17921820 updateVerboseLogging();
17931821
1794− // Now that we've loaded the menu and thus switched to the previous display plugin
1795− // we can unlock the desktop repositioning code, since all the positions will be
1796− // relative to the desktop size for this plugin
1797− auto offscreenUi = getOffscreenUI();
1798− connect(offscreenUi.data(), &OffscreenUi::desktopReady, []() {
1799− auto offscreenUi = getOffscreenUI();
1800− auto desktop = offscreenUi->getDesktop();
1801− if (desktop) {
1802− desktop->setProperty("repositionLocked", false);
1803− }
1804− });
1805−
1806− connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
1807−#if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML)
1808− // Do not show login dialog if requested not to on the command line
1809− QString hifiNoLoginCommandLineKey = QString("--").append(HIFI_NO_LOGIN_COMMAND_LINE_KEY);
1810− int index = arguments().indexOf(hifiNoLoginCommandLineKey);
1811− if (index != -1) {
1812− resumeAfterLoginDialogActionTaken();
1813− return;
1814− }
1815−
1816− showLoginScreen();
1817−#else
1818− resumeAfterLoginDialogActionTaken();
1819−#endif
1820− });
1821−
18221822 // Make sure we don't time out during slow operations at startup
18231823 updateHeartbeat();
18241824 QTimer* settingsTimer = new QTimer();