diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 8fbfc664c3f..c7cae10404a 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -64,6 +64,8 @@ void QmlProfilerRunner::start() disconnect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, nullptr); QmlProfilerTool::instance()->finalizeRunControl(this); + connect(this, &QmlProfilerRunner::stopped, + QmlProfilerTool::instance(), &QmlProfilerTool::handleStop); d->m_profilerState = QmlProfilerTool::instance()->stateManager(); QTC_ASSERT(d->m_profilerState, return); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 810d373887f..1588106480c 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -362,23 +362,6 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) } } - auto handleStop = [this, runControl] { - if (!d->m_toolBusy) - return; - - d->m_toolBusy = false; - updateRunActions(); - disconnect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop); - - // If we're still trying to connect, stop now. - if (d->m_profilerConnections->isConnecting()) { - showNonmodalWarning(Tr::tr("The application finished before a connection could be " - "established. No data was loaded.")); - } - d->m_profilerConnections->disconnectFromServer(); - }; - - connect(runWorker, &QmlProfilerRunner::stopped, this, handleStop); connect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop); updateRunActions(); @@ -432,6 +415,23 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); } +void QmlProfilerTool::handleStop() +{ + if (!d->m_toolBusy) + return; + + d->m_toolBusy = false; + updateRunActions(); + disconnect(d->m_stopAction, &QAction::triggered, nullptr, nullptr); + + // If we're still trying to connect, stop now. + if (d->m_profilerConnections->isConnecting()) { + showNonmodalWarning(Tr::tr("The application finished before a connection could be " + "established. No data was loaded.")); + } + d->m_profilerConnections->disconnectFromServer(); +} + void QmlProfilerTool::recordingButtonChanged(bool recording) { // clientRecording is our intention for new sessions. That may differ from the state of the diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 65bdc228c73..7477937d3f7 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -31,6 +31,7 @@ public: static QmlProfilerTool *instance(); void finalizeRunControl(QmlProfilerRunner *runWorker); + void handleStop(); bool prepareTool(); ProjectExplorer::RunControl *attachToWaitingApplication();