mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
46c6a3cb92
commit
c7c5dac621
1 changed files with 3 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue