QmlProfiler: Defer chained state changes

If the state is changed again from a signal handler before all handlers
for the signal have been processed, we can get confusing results. Defer
those calls.

Change-Id: I73f7b8faa48ee00c17fdedb4140823d7a1b13435
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2018-01-16 17:58:23 +01:00
parent 9a57f19552
commit 5555b7137b

View File

@@ -743,8 +743,11 @@ void QmlProfilerTool::clientsDisconnected()
}
// ... and return to the "base" state
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying)
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) {
QTimer::singleShot(0, d->m_profilerState, [this]() {
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
});
}
}
void addFeatureToMenu(QMenu *menu, ProfileFeature feature, quint64 enabledFeatures)
@@ -879,7 +882,9 @@ void QmlProfilerTool::profilerStateChanged()
d->m_profilerConnections->stopRecording();
} else {
// Directly transition to idle
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
QTimer::singleShot(0, d->m_profilerState, [this]() {
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
});
}
break;
default: