summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-04 14:40:53 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-04 16:12:52 -0700
commitc7c5dac6211f42aff0414692645ab338c15118ec (patch)
treeb464b132012a2e71a6edff289b66eeb9ed971dc4 /mobile-widgets
parent46c6a3cb92661a83797eacde64c38a2fdd71e06c (diff)
downloadsubsurface-c7c5dac6211f42aff0414692645ab338c15118ec.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp4
1 files changed, 3 insertions, 1 deletions
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();
}