forked from qt-creator/qt-creator
ProjectExplorer: Split Target and ToolRunners into smaller tasks
This increases re-usability of activities like 'port gathering', and makes their use less dependent on actual device implementations. Change-Id: I017cb74874f2b38c487ba2d03906a675d5618647 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -67,7 +67,6 @@ namespace QmlProfiler {
|
||||
class QmlProfilerRunControl::QmlProfilerRunControlPrivate
|
||||
{
|
||||
public:
|
||||
Internal::QmlProfilerTool *m_tool = 0;
|
||||
QmlProfilerStateManager *m_profilerState = 0;
|
||||
QTimer m_noDebugOutputTimer;
|
||||
};
|
||||
@@ -76,15 +75,13 @@ public:
|
||||
// QmlProfilerRunControl
|
||||
//
|
||||
|
||||
QmlProfilerRunControl::QmlProfilerRunControl(RunConfiguration *runConfiguration,
|
||||
Internal::QmlProfilerTool *tool)
|
||||
QmlProfilerRunControl::QmlProfilerRunControl(RunConfiguration *runConfiguration)
|
||||
: RunControl(runConfiguration, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
|
||||
, d(new QmlProfilerRunControlPrivate)
|
||||
{
|
||||
setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
|
||||
setSupportsReRunning(false);
|
||||
|
||||
d->m_tool = tool;
|
||||
// Only wait 4 seconds for the 'Waiting for connection' on application output, then just try to connect
|
||||
// (application output might be redirected / blocked)
|
||||
d->m_noDebugOutputTimer.setSingleShot(true);
|
||||
@@ -104,7 +101,7 @@ QmlProfilerRunControl::~QmlProfilerRunControl()
|
||||
void QmlProfilerRunControl::start()
|
||||
{
|
||||
reportApplicationStart();
|
||||
d->m_tool->finalizeRunControl(this);
|
||||
Internal::QmlProfilerTool::instance()->finalizeRunControl(this);
|
||||
QTC_ASSERT(d->m_profilerState, reportApplicationStop(); return);
|
||||
|
||||
QTC_ASSERT(connection().is<AnalyzerConnection>(), reportApplicationStop(); return);
|
||||
|
||||
@@ -32,15 +32,12 @@
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
namespace Internal { class QmlProfilerTool; }
|
||||
|
||||
class QmlProfilerRunControl : public ProjectExplorer::RunControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlProfilerRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
|
||||
Internal::QmlProfilerTool *tool);
|
||||
QmlProfilerRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
~QmlProfilerRunControl() override;
|
||||
|
||||
void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
|
||||
|
||||
@@ -92,10 +92,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
|
||||
connection.analyzerPort = LocalQmlProfilerRunner::findFreePort(connection.analyzerHost);
|
||||
}
|
||||
|
||||
auto runControl = qobject_cast<QmlProfilerRunControl *>
|
||||
(Debugger::createAnalyzerRunControl(runConfiguration, mode));
|
||||
QTC_ASSERT(runControl, return 0);
|
||||
|
||||
auto runControl = new QmlProfilerRunControl(runConfiguration);
|
||||
runControl->setRunnable(runnable);
|
||||
runControl->setConnection(connection);
|
||||
|
||||
|
||||
@@ -127,9 +127,12 @@ public:
|
||||
bool m_toolBusy = false;
|
||||
};
|
||||
|
||||
static QmlProfilerTool *s_instance;
|
||||
|
||||
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
: QObject(parent), d(new QmlProfilerToolPrivate)
|
||||
{
|
||||
s_instance = this;
|
||||
setObjectName(QLatin1String("QmlProfilerTool"));
|
||||
|
||||
d->m_profilerState = new QmlProfilerStateManager(this);
|
||||
@@ -244,8 +247,9 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
// is available, then we can populate the file finder
|
||||
d->m_profilerModelManager->populateFileFinder();
|
||||
|
||||
auto runControlCreator = [this](RunConfiguration *runConfiguration, Core::Id) {
|
||||
return createRunControl(runConfiguration);
|
||||
auto runWorkerCreator = [this](RunControl *runControl) {
|
||||
// return createRunControl(runConfiguration);
|
||||
return nullptr; // FIXME
|
||||
};
|
||||
|
||||
QString description = tr("The QML Profiler can be used to find performance "
|
||||
@@ -254,7 +258,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
d->m_startAction = Debugger::createStartAction();
|
||||
d->m_stopAction = Debugger::createStopAction();
|
||||
|
||||
Debugger::registerAction(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, runControlCreator);
|
||||
RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, runWorkerCreator);
|
||||
act = new QAction(tr("QML Profiler"), this);
|
||||
act->setToolTip(description);
|
||||
menu->addAction(ActionManager::registerAction(act, "QmlProfiler.Local"),
|
||||
@@ -270,7 +274,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
act->setEnabled(d->m_startAction->isEnabled());
|
||||
});
|
||||
|
||||
Debugger::registerAction(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, runControlCreator);
|
||||
act = new QAction(tr("QML Profiler (External)"), this);
|
||||
act->setToolTip(description);
|
||||
menu->addAction(ActionManager::registerAction(act, "QmlProfiler.Remote"),
|
||||
@@ -305,6 +308,11 @@ QmlProfilerTool::~QmlProfilerTool()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QmlProfilerTool *QmlProfilerTool::instance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void QmlProfilerTool::updateRunActions()
|
||||
{
|
||||
if (d->m_toolBusy) {
|
||||
@@ -336,11 +344,11 @@ RunControl *QmlProfilerTool::createRunControl(RunConfiguration *runConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
auto runControl = new QmlProfilerRunControl(runConfiguration, this);
|
||||
auto runControl = new QmlProfilerRunControl(runConfiguration);
|
||||
connect(runControl, &RunControl::finished, this, [this, runControl] {
|
||||
d->m_toolBusy = false;
|
||||
updateRunActions();
|
||||
disconnect(d->m_stopAction, &QAction::triggered, runControl, &QmlProfilerRunControl::stop);
|
||||
disconnect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::stop);
|
||||
});
|
||||
|
||||
connect(d->m_stopAction, &QAction::triggered, runControl, &QmlProfilerRunControl::stop);
|
||||
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
explicit QmlProfilerTool(QObject *parent);
|
||||
~QmlProfilerTool();
|
||||
|
||||
static QmlProfilerTool *instance();
|
||||
|
||||
ProjectExplorer::RunControl *createRunControl(ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
void finalizeRunControl(QmlProfilerRunControl *runControl);
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "localqmlprofilerrunner_test.h"
|
||||
|
||||
#include "../qmlprofilerruncontrol.h"
|
||||
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <debugger/analyzer/analyzerstartparameters.h>
|
||||
#include <QtTest>
|
||||
@@ -57,8 +60,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
// should not be used anywhere but cannot be empty
|
||||
configuration.socket = connection.analyzerSocket = QString("invalid");
|
||||
|
||||
rc = Debugger::createAnalyzerRunControl(
|
||||
nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
rc = new QmlProfilerRunControl(nullptr);
|
||||
rc->setConnection(connection);
|
||||
auto runner = new LocalQmlProfilerRunner(configuration, rc);
|
||||
connectRunner(runner);
|
||||
@@ -79,8 +81,7 @@ void LocalQmlProfilerRunnerTest::testRunner1()
|
||||
configuration.debuggee.commandLineArguments = QString("-test QmlProfiler,");
|
||||
|
||||
delete rc;
|
||||
rc = Debugger::createAnalyzerRunControl(
|
||||
nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
rc = new QmlProfilerRunControl(nullptr);
|
||||
rc->setConnection(connection);
|
||||
auto runner = new LocalQmlProfilerRunner(configuration, rc);
|
||||
connectRunner(runner);
|
||||
@@ -100,8 +101,7 @@ void LocalQmlProfilerRunnerTest::testRunner2()
|
||||
connection.analyzerSocket.clear();
|
||||
configuration.port = connection.analyzerPort =
|
||||
LocalQmlProfilerRunner::findFreePort(connection.analyzerHost);
|
||||
rc = Debugger::createAnalyzerRunControl(
|
||||
nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
rc = new QmlProfilerRunControl(nullptr);
|
||||
rc->setConnection(connection);
|
||||
auto runner = new LocalQmlProfilerRunner(configuration, rc);
|
||||
connectRunner(runner);
|
||||
|
||||
Reference in New Issue
Block a user