From c7c5dac6211f42aff0414692645ab338c15118ec Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 4 Apr 2020 14:40:53 -0700 Subject: mobile/startup: fix potential crash when switching back and forth If the user switches away from Subsurface-mobile and back while we are in our initialization phase, that code might run more than once leading to undesirable results. Signed-off-by: Dirk Hohndel --- mobile-widgets/qmlmanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mobile-widgets') diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 99811d66c..a610b36cd 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -308,6 +308,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), void QMLManager::applicationStateChanged(Qt::ApplicationState state) { + static bool initializeOnce = false; QString stateText; switch (state) { case Qt::ApplicationActive: stateText = "active"; break; @@ -321,8 +322,9 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state) stateText.append((unsavedChanges() ? QLatin1String("") : QLatin1String("no ")) + QLatin1String("unsaved changes")); appendTextToLog(stateText); - if (state == Qt::ApplicationActive && !m_initialized) { + if (state == Qt::ApplicationActive && !m_initialized && !initializeOnce) { // once the app UI is displayed, finish our setup and mark the app as initialized + initializeOnce = true; finishSetup(); appInitialized(); } -- cgit v1.2.3-70-g09d2