From a46fe36bce87eb96744d8bfde86cbfa3fac5f417 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 17 Nov 2014 17:32:52 +0100 Subject: [PATCH] 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 --- src/plugins/qmlprofiler/qmlprofilertool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index eddf8abbe5a..53466822f73 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -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) {