QmlProfiler: Fix toggling of internal client recording state

We cannot just set it unconditionally on setRecording() because the
client recording state is supposed to reflect the user's intention.
Instead, if the recording button's state differs from the intention
and then spontaneously changes to match it (through a change in the
application), we toggle the client recording state twice to make sure
everything is properly synchronized.

Change-Id: I070d38364e63ab9cf0597fabed3d326ac3685589
Task-number: QTCREATORBUG-13322, QTCREATORBUG-13430
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2014-11-17 17:32:52 +01:00
parent 9411cd2db3
commit a46fe36bce

View File

@@ -328,14 +328,21 @@ void QmlProfilerTool::populateFileFinder(QString projectDirectory, QString activ
void QmlProfilerTool::recordingButtonChanged(bool recording)
{
// clientRecording is our intention for new sessions. That may differ from the state of the
// current session, as indicated by the button. To synchronize it, toggle once.
if (recording && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
if (checkForUnsavedNotes()) {
clearData(); // clear right away, before the application starts
if (d->m_profilerState->clientRecording())
d->m_profilerState->setClientRecording(false);
d->m_profilerState->setClientRecording(true);
} else {
d->m_recordButton->setChecked(false);
}
} else {
if (d->m_profilerState->clientRecording() == recording)
d->m_profilerState->setClientRecording(!recording);
d->m_profilerState->setClientRecording(recording);
}
}
@@ -348,7 +355,6 @@ void QmlProfilerTool::setRecording(bool recording)
QLatin1String(":/qmlprofiler/recordOff.png")));
d->m_recordButton->setChecked(recording);
d->m_profilerState->setClientRecording(recording);
// manage timer
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) {