From 160f4b9f7c91f9baacc8f1dafa87e7f25714e774 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 6 Jan 2025 14:03:03 +0100 Subject: [PATCH] QmlProfilerRunner: Drop private data Change-Id: I8f45174cec9de3c88056bbe364da1f7c40820b36 Reviewed-by: hjk --- .../qmlprofiler/qmlprofilerruncontrol.cpp | 56 ++++++------------- .../qmlprofiler/qmlprofilerruncontrol.h | 4 -- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 189ec286374..35030a5b51d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -33,23 +33,8 @@ using namespace ProjectExplorer; namespace QmlProfiler::Internal { -// -// QmlProfilerRunControlPrivate -// - -class QmlProfilerRunner::QmlProfilerRunnerPrivate -{ -public: - QPointer m_profilerState; -}; - -// -// QmlProfilerRunControl -// - QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl) : RunWorker(runControl) - , d(new QmlProfilerRunnerPrivate) { setId("QmlProfilerRunner"); runControl->requestQmlChannel(); @@ -57,29 +42,21 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl) setSupportsReRunning(false); } -QmlProfilerRunner::~QmlProfilerRunner() -{ - delete d; -} - void QmlProfilerRunner::start() { - if (d->m_profilerState) - disconnect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, nullptr); - QmlProfilerTool::instance()->finalizeRunControl(runControl()); connect(this, &QmlProfilerRunner::stopped, QmlProfilerTool::instance(), &QmlProfilerTool::handleStop); - d->m_profilerState = QmlProfilerTool::instance()->stateManager(); - QTC_ASSERT(d->m_profilerState, return); + QmlProfilerStateManager *stateManager = QmlProfilerTool::instance()->stateManager(); + QTC_ASSERT(stateManager, return); - connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, [this] { - if (d->m_profilerState->currentState() == QmlProfilerStateManager::Idle) + connect(stateManager, &QmlProfilerStateManager::stateChanged, this, [this, stateManager] { + if (stateManager->currentState() == QmlProfilerStateManager::Idle) reportStopped(); }); QmlProfilerClientManager *clientManager = QmlProfilerTool::instance()->clientManager(); - connect(clientManager, &QmlProfilerClientManager::connectionFailed, this, [this, clientManager] { + connect(clientManager, &QmlProfilerClientManager::connectionFailed, this, [this, clientManager, stateManager] { auto infoBox = new QMessageBox(ICore::dialogParent()); infoBox->setIcon(QMessageBox::Critical); infoBox->setWindowTitle(QGuiApplication::applicationDisplayName()); @@ -96,19 +73,17 @@ void QmlProfilerRunner::start() infoBox->setDefaultButton(QMessageBox::Retry); infoBox->setModal(true); - connect(infoBox, &QDialog::finished, this, [this, clientManager, interval](int result) { - const auto cancelProcess = [this] { - QTC_ASSERT(d->m_profilerState, return); - - switch (d->m_profilerState->currentState()) { + connect(infoBox, &QDialog::finished, this, [this, clientManager, stateManager, interval](int result) { + const auto cancelProcess = [this, stateManager] { + switch (stateManager->currentState()) { case QmlProfilerStateManager::Idle: break; case QmlProfilerStateManager::AppRunning: - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying); + stateManager->setCurrentState(QmlProfilerStateManager::AppDying); break; default: { const QString message = QString::fromLatin1("Unexpected process termination requested with state %1 in %2:%3") - .arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__)); + .arg(stateManager->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__)); qWarning("%s", qPrintable(message)); return; } @@ -142,18 +117,19 @@ void QmlProfilerRunner::start() void QmlProfilerRunner::stop() { - if (!d->m_profilerState) { + QmlProfilerStateManager *stateManager = QmlProfilerTool::instance()->stateManager(); + if (!stateManager) { reportStopped(); return; } - switch (d->m_profilerState->currentState()) { + switch (stateManager->currentState()) { case QmlProfilerStateManager::AppRunning: - d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopRequested); + stateManager->setCurrentState(QmlProfilerStateManager::AppStopRequested); break; case QmlProfilerStateManager::AppStopRequested: // Pressed "stop" a second time. Kill the application without collecting data - d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); + stateManager->setCurrentState(QmlProfilerStateManager::Idle); reportStopped(); break; case QmlProfilerStateManager::Idle: @@ -162,7 +138,7 @@ void QmlProfilerRunner::stop() break; default: { const QString message = QString::fromLatin1("Unexpected engine stop from state %1 in %2:%3") - .arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__)); + .arg(stateManager->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__)); qWarning("%s", qPrintable(message)); } break; diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index 03e738e9b8a..a1b6cdb6b05 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -18,14 +18,10 @@ class QmlProfilerRunner : public ProjectExplorer::RunWorker { public: QmlProfilerRunner(ProjectExplorer::RunControl *runControl); - ~QmlProfilerRunner() override; private: void start() override; void stop() override; - - class QmlProfilerRunnerPrivate; - QmlProfilerRunnerPrivate *d; }; ProjectExplorer::RunWorker *createLocalQmlProfilerWorker(ProjectExplorer::RunControl *runControl);