forked from qt-creator/qt-creator
QmlProfiler: Simplify QmlProfilerRunner
Remove registerProfilerStateManager() and connect to state manager's signal directly from the start() function. Remove Q_OBJECT macro. Change-Id: Id03486f077c81909fbe0889bb342ee7595631e9d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "qmlprofilerruncontrol.h"
|
||||
|
||||
#include "qmlprofilerstatemanager.h"
|
||||
#include "qmlprofilertool.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -23,8 +24,6 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/url.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -61,9 +60,17 @@ QmlProfilerRunner::~QmlProfilerRunner()
|
||||
|
||||
void QmlProfilerRunner::start()
|
||||
{
|
||||
if (!d->m_profilerState)
|
||||
if (d->m_profilerState)
|
||||
disconnect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, nullptr);
|
||||
|
||||
QmlProfilerTool::instance()->finalizeRunControl(this);
|
||||
d->m_profilerState = QmlProfilerTool::instance()->stateManager();
|
||||
QTC_ASSERT(d->m_profilerState, return);
|
||||
|
||||
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, [this] {
|
||||
if (d->m_profilerState->currentState() == QmlProfilerStateManager::Idle)
|
||||
reportStopped();
|
||||
});
|
||||
reportStarted();
|
||||
}
|
||||
|
||||
@@ -116,32 +123,6 @@ void QmlProfilerRunner::cancelProcess()
|
||||
runControl()->initiateStop();
|
||||
}
|
||||
|
||||
void QmlProfilerRunner::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
|
||||
{
|
||||
// disconnect old
|
||||
if (d->m_profilerState)
|
||||
disconnect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
||||
this, &QmlProfilerRunner::profilerStateChanged);
|
||||
|
||||
d->m_profilerState = profilerState;
|
||||
|
||||
// connect
|
||||
if (d->m_profilerState)
|
||||
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
|
||||
this, &QmlProfilerRunner::profilerStateChanged);
|
||||
}
|
||||
|
||||
void QmlProfilerRunner::profilerStateChanged()
|
||||
{
|
||||
switch (d->m_profilerState->currentState()) {
|
||||
case QmlProfilerStateManager::Idle:
|
||||
reportStopped();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RunWorker *createLocalQmlProfilerWorker(RunControl *runControl)
|
||||
{
|
||||
auto worker = new ProcessRunner(runControl);
|
||||
|
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofilerstatemanager.h"
|
||||
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
@@ -18,21 +16,16 @@ namespace Internal {
|
||||
|
||||
class QmlProfilerRunner : public ProjectExplorer::RunWorker
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlProfilerRunner(ProjectExplorer::RunControl *runControl);
|
||||
~QmlProfilerRunner() override;
|
||||
|
||||
void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
|
||||
void cancelProcess();
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
||||
void profilerStateChanged();
|
||||
|
||||
class QmlProfilerRunnerPrivate;
|
||||
QmlProfilerRunnerPrivate *d;
|
||||
};
|
||||
|
@@ -178,7 +178,7 @@ QmlProfilerTool::QmlProfilerTool()
|
||||
d->m_clearButton->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
|
||||
d->m_clearButton->setToolTip(Tr::tr("Discard data"));
|
||||
|
||||
connect(d->m_clearButton, &QAbstractButton::clicked, [this](){
|
||||
connect(d->m_clearButton, &QAbstractButton::clicked, [this] {
|
||||
if (checkForUnsavedNotes())
|
||||
clearData();
|
||||
});
|
||||
@@ -382,7 +382,6 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
|
||||
connect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop);
|
||||
|
||||
updateRunActions();
|
||||
runWorker->registerProfilerStateManager(d->m_profilerState);
|
||||
|
||||
//
|
||||
// Initialize m_projectFinder
|
||||
@@ -391,7 +390,7 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
|
||||
d->m_profilerModelManager->populateFileFinder(runControl->target());
|
||||
|
||||
connect(d->m_profilerConnections, &QmlProfilerClientManager::connectionFailed,
|
||||
runWorker, [this, runWorker]() {
|
||||
runWorker, [this, runWorker] {
|
||||
auto infoBox = new QMessageBox(ICore::dialogParent());
|
||||
infoBox->setIcon(QMessageBox::Critical);
|
||||
infoBox->setWindowTitle(QGuiApplication::applicationDisplayName());
|
||||
|
Reference in New Issue
Block a user