diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-10-20 12:48:26 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-10-20 11:43:14 +0000 |
commit | bd22de47e7c760753af06fdf02141449588f3323 (patch) | |
tree | d5903b35f2813e830b931f04c2dc08e8cdc8cb4f /src | |
parent | 88c5b47e535d91f3db99882d5b50b263b46f223c (diff) | |
download | qt-creator-bd22de47e7c760753af06fdf02141449588f3323.tar.gz |
QmlProfiler: Prevent interaction with buttons while loading data
You could trigger invalid states by pressing the recording button
while the profiler was waiting for data to be loaded from the
application or by pressing the "stop" button twice. Now the buttons
are disabled when they don't make any sense. In particular you cannot
clear, change features, filter the display while recording and you
cannot toggle the recording while loading. Pressing the "stop" button
twice will cancel the loading now, similar to what happens if you
first disable recording and then stop while the data is loaded.
Change-Id: Ie5133f4bed76593dedc9763b778a2c5c17187543
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp | 15 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerruncontrol.h | 1 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.cpp | 41 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.h | 1 |
4 files changed, 46 insertions, 12 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 62d93db3ae..9a81a408c8 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -125,10 +125,13 @@ void QmlProfilerRunControl::stopEngine() QTC_ASSERT(d->m_profilerState, return); switch (d->m_profilerState->currentState()) { - case QmlProfilerStateManager::AppRunning : { + case QmlProfilerStateManager::AppRunning: d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopRequested); break; - } + case QmlProfilerStateManager::AppStopRequested: + // Pressed "stop" a second time. Kill the application without collecting data + d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); + break; case QmlProfilerStateManager::Idle: case QmlProfilerStateManager::AppDying: // valid, but no further action is needed @@ -260,4 +263,12 @@ void QmlProfilerRunControl::profilerStateChanged() } } +RunControl::StopResult QmlProfiler::QmlProfilerRunControl::stop() +{ + StopResult result = Analyzer::AnalyzerRunControl::stop(); + if (d->m_profilerState->currentState() != QmlProfilerStateManager::Idle) + m_isRunning = true; + return result; +} + } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index 812d660d62..14fcccef19 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -50,6 +50,7 @@ public: void registerProfilerStateManager( QmlProfilerStateManager *profilerState ); void notifyRemoteSetupDone(quint16 port); + StopResult stop(); signals: void processRunning(quint16 port); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 37e4d6ad22..f80768dd98 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -393,9 +393,6 @@ void QmlProfilerTool::setRecording(bool recording) } else { d->m_recordingTimer.stop(); } - d->m_recordButton->menu()->setEnabled(!recording); - } else { - d->m_recordButton->menu()->setEnabled(true); } } @@ -451,6 +448,14 @@ void QmlProfilerTool::clearDisplay() updateTimeDisplay(); } +void QmlProfilerTool::setButtonsEnabled(bool enable) +{ + d->m_clearButton->setEnabled(enable); + d->m_displayFeaturesButton->setEnabled(enable); + d->m_searchButton->setEnabled(enable); + d->m_recordFeaturesMenu->setEnabled(enable); +} + bool QmlProfilerTool::prepareTool() { if (d->m_recordButton->isChecked()) { @@ -625,7 +630,8 @@ void QmlProfilerTool::restoreFeatureVisibility() void QmlProfilerTool::clientsDisconnected() { // If the application stopped by itself, check if we have all the data - if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) { + if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying || + d->m_profilerState->currentState() == QmlProfilerStateManager::Idle) { if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData) { showNonmodalWarning(tr("Application finished before loading profiled data.\n" "Please use the stop button instead.")); @@ -633,7 +639,8 @@ void QmlProfilerTool::clientsDisconnected() } // ... and return to the "base" state - d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); + if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) + d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); } // If the connection is closed while the app is still running, no special action is needed } @@ -687,13 +694,21 @@ void QmlProfilerTool::profilerDataModelStateChanged() { switch (d->m_profilerModelManager->state()) { case QmlProfilerModelManager::Empty : + d->m_recordButton->setEnabled(true); + setButtonsEnabled(true); break; case QmlProfilerModelManager::ClearingData : + d->m_recordButton->setEnabled(false); + setButtonsEnabled(false); clearDisplay(); break; case QmlProfilerModelManager::AcquiringData : + d->m_recordButton->setEnabled(true); // Press recording button to stop recording + setButtonsEnabled(false); // Other buttons disabled + break; case QmlProfilerModelManager::ProcessingData : - // nothing to be done for these two + d->m_recordButton->setEnabled(false); + setButtonsEnabled(false); break; case QmlProfilerModelManager::Done : if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStopRequested) @@ -701,6 +716,8 @@ void QmlProfilerTool::profilerDataModelStateChanged() showSaveOption(); updateTimeDisplay(); restoreFeatureVisibility(); + d->m_recordButton->setEnabled(true); + setButtonsEnabled(true); break; default: break; @@ -749,6 +766,11 @@ void QmlProfilerTool::profilerStateChanged() // when the app finishes, set recording display to client status setRecording(d->m_profilerState->clientRecording()); break; + case QmlProfilerStateManager::AppStopRequested: + // Don't allow toggling the recording while data is loaded when application quits + if (d->m_profilerState->serverRecording()) + d->m_recordButton->setEnabled(false); + break; default: // no special action needed for other states break; @@ -781,15 +803,14 @@ void QmlProfilerTool::serverRecordingChanged() showSaveDialog(); setRecording(true); - d->m_clearButton->setEnabled(false); clearData(); d->m_profilerModelManager->prepareForWriting(); } else { setRecording(false); - d->m_clearButton->setEnabled(true); + + // changes back once loading is finished, see profilerDataModelStateChanged() + d->m_recordButton->setEnabled(false); } - } else { - d->m_clearButton->setEnabled(true); } } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 5aa9fc75b0..c55116bb40 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -106,6 +106,7 @@ private: void updateFeatures(quint64 features); bool checkForUnsavedNotes(); void restoreFeatureVisibility(); + void setButtonsEnabled(bool enable); class QmlProfilerToolPrivate; QmlProfilerToolPrivate *d; |