diff options
author | Christiaan Janssen <christiaan.janssen@digia.com> | 2013-08-06 16:47:48 +0200 |
---|---|---|
committer | Christiaan Janssen <christiaan.janssen@digia.com> | 2013-08-08 12:23:13 +0300 |
commit | 6a1832cd29aba826b1a2e2380f0fb2fb16a735a5 (patch) | |
tree | 932091f7b4572696224d41ade22e419f612de61f | |
parent | cf287b5e2872fcdef3fe14bca8113907aea89e02 (diff) | |
download | qt-creator-6a1832cd29aba826b1a2e2380f0fb2fb16a735a5.tar.gz |
QmlProfiler: merge back changes in creator/master
Change-Id: Ib9a13c1feb08defa1b8cf1fc308837d71c858fae
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r-- | plugins/qmlprofiler/localqmlprofilerrunner.cpp | 26 | ||||
-rw-r--r-- | plugins/qmlprofiler/localqmlprofilerrunner.h | 10 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilerengine.cpp | 122 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilerengine.h | 15 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilerplugin.cpp | 9 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp | 81 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilerruncontrolfactory.h | 2 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilertool.cpp | 85 | ||||
-rw-r--r-- | plugins/qmlprofiler/qmlprofilertool.h | 11 |
9 files changed, 132 insertions, 229 deletions
diff --git a/plugins/qmlprofiler/localqmlprofilerrunner.cpp b/plugins/qmlprofiler/localqmlprofilerrunner.cpp index 6eb06223be..14f7de97dd 100644 --- a/plugins/qmlprofiler/localqmlprofilerrunner.cpp +++ b/plugins/qmlprofiler/localqmlprofilerrunner.cpp @@ -45,7 +45,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner( RunConfiguration *runConfiguration, const Analyzer::AnalyzerStartParameters &sp, QString *errorMessage, - QmlProfilerEngine *engine) + QmlProfilerRunControl *engine) { QmlProjectManager::QmlProjectRunConfiguration *rc1 = qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration); @@ -81,7 +81,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner( } LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration, - QmlProfilerEngine *engine) : + QmlProfilerRunControl *engine) : AbstractQmlProfilerRunner(engine), m_configuration(configuration), m_engine(engine) @@ -92,12 +92,12 @@ LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuratio LocalQmlProfilerRunner::~LocalQmlProfilerRunner() { - disconnect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int))); + disconnect(); } void LocalQmlProfilerRunner::start() { - if (m_engine->mode() != Analyzer::StartQml) + if (m_engine->mode() != Analyzer::StartLocal) return; QString arguments = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_configuration.port); @@ -111,26 +111,32 @@ void LocalQmlProfilerRunner::start() m_launcher.setWorkingDirectory(m_configuration.workingDirectory); m_launcher.setEnvironment(m_configuration.environment); - connect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int))); + connect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)), + this, SLOT(spontaneousStop(int,QProcess::ExitStatus))); m_launcher.start(ProjectExplorer::ApplicationLauncher::Gui, m_configuration.executable, arguments); emit started(); } -void LocalQmlProfilerRunner::spontaneousStop(int exitCode) +void LocalQmlProfilerRunner::spontaneousStop(int exitCode, QProcess::ExitStatus status) { - if (QmlProfilerPlugin::debugOutput) - qWarning("QmlProfiler: Application exited (exit code %d).", exitCode); + if (QmlProfilerPlugin::debugOutput) { + if (status == QProcess::CrashExit) + qWarning("QmlProfiler: Application crashed."); + else + qWarning("QmlProfiler: Application exited (exit code %d).", exitCode); + } - disconnect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int))); + disconnect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)), + this, SLOT(spontaneousStop(int,QProcess::ExitStatus))); emit stopped(); } void LocalQmlProfilerRunner::stop() { - if (m_engine->mode() != Analyzer::StartQml) + if (m_engine->mode() != Analyzer::StartLocal) return; if (QmlProfilerPlugin::debugOutput) diff --git a/plugins/qmlprofiler/localqmlprofilerrunner.h b/plugins/qmlprofiler/localqmlprofilerrunner.h index 37591917da..540f472241 100644 --- a/plugins/qmlprofiler/localqmlprofilerrunner.h +++ b/plugins/qmlprofiler/localqmlprofilerrunner.h @@ -41,7 +41,7 @@ namespace Analyzer { class AnalyzerStartParameters; } namespace QmlProfiler { namespace Internal { -class QmlProfilerEngine; +class QmlProfilerRunControl; class LocalQmlProfilerRunner : public AbstractQmlProfilerRunner { Q_OBJECT @@ -58,7 +58,7 @@ public: static LocalQmlProfilerRunner *createLocalRunner(ProjectExplorer::RunConfiguration *runConfiguration, const Analyzer::AnalyzerStartParameters &sp, QString *errorMessage, - QmlProfilerEngine *engine); + QmlProfilerRunControl *engine); ~LocalQmlProfilerRunner(); @@ -68,15 +68,15 @@ public: virtual quint16 debugPort() const; private slots: - void spontaneousStop(int exitCode); + void spontaneousStop(int exitCode, QProcess::ExitStatus status); private: - LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerEngine *engine); + LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine); private: Configuration m_configuration; ProjectExplorer::ApplicationLauncher m_launcher; - QmlProfilerEngine *m_engine; + QmlProfilerRunControl *m_engine; }; } // namespace Internal diff --git a/plugins/qmlprofiler/qmlprofilerengine.cpp b/plugins/qmlprofiler/qmlprofilerengine.cpp index 1127eb0d14..0dff45f4d5 100644 --- a/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -33,7 +33,6 @@ #include <analyzerbase/analyzermanager.h> #include <coreplugin/icore.h> -#include <debugger/debuggerrunconfigurationaspect.h> #include <utils/qtcassert.h> #include <coreplugin/helpmanager.h> #include <projectexplorer/projectexplorerconstants.h> @@ -61,74 +60,26 @@ namespace Internal { // QmlProfilerEnginePrivate // -class QmlProfilerEngine::QmlProfilerEnginePrivate +class QmlProfilerRunControl::QmlProfilerEnginePrivate { public: - QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {} - ~QmlProfilerEnginePrivate() { delete m_runner; } - - bool attach(const QString &address, uint port); - - QmlProfilerEngine *q; + QmlProfilerEnginePrivate() : m_running(false) {} QmlProfilerStateManager *m_profilerState; - QTimer m_noDebugOutputTimer; QmlDebug::QmlOutputParser m_outputParser; + bool m_running; }; -AbstractQmlProfilerRunner * -QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunConfiguration *runConfiguration, - QObject *parent) -{ - AbstractQmlProfilerRunner *runner = 0; - if (!runConfiguration) // attaching - return 0; - - QmlProjectManager::QmlProjectRunConfiguration *rc1 = - qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration); - LocalApplicationRunConfiguration *rc2 = - qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); - // Supports only local run configurations - if (!rc1 && !rc2) - return 0; - - ProjectExplorer::EnvironmentAspect *environment - = runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>(); - QTC_ASSERT(environment, return 0); - LocalQmlProfilerRunner::Configuration conf; - if (rc1) { - // This is a "plain" .qmlproject. - conf.executable = rc1->observerPath(); - conf.executableArguments = rc1->viewerArguments(); - conf.workingDirectory = rc1->workingDirectory(); - conf.environment = environment->environment(); - } else { - // FIXME: Check. - conf.executable = rc2->executable(); - conf.executableArguments = rc2->commandLineArguments(); - conf.workingDirectory = rc2->workingDirectory(); - conf.environment = environment->environment(); - } - const ProjectExplorer::IDevice::ConstPtr device = - ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit()); - QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0); - conf.port = q->m_sp.analyzerPort; - runner = new LocalQmlProfilerRunner(conf, parent); - return runner; -} - // // QmlProfilerEngine // -QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, +QmlProfilerRunControl::QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration) - : d(new QmlProfilerEnginePrivate(this)) + : AnalyzerRunControl(sp, runConfiguration) + , d(new QmlProfilerEnginePrivate) { - m_sp = sp; - m_runConfig = runConfiguration; - d->m_profilerState = 0; // Only wait 4 seconds for the 'Waiting for connection' on application output, then just try to connect @@ -146,14 +97,14 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp this, SLOT(wrongSetupMessageBox(QString))); } -QmlProfilerEngine::~QmlProfilerEngine() +QmlProfilerRunControl::~QmlProfilerRunControl() { if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) - stop(); + stopEngine(); delete d; } -bool QmlProfilerEngine::start() +bool QmlProfilerRunControl::startEngine() { QTC_ASSERT(d->m_profilerState, return false); @@ -169,24 +120,7 @@ bool QmlProfilerEngine::start() } } - d->m_runner = d->createRunner(runConfiguration(), this); - - if (LocalQmlProfilerRunner *qmlRunner = qobject_cast<LocalQmlProfilerRunner *>(d->m_runner)) { - if (!qmlRunner->hasExecutable()) { - showNonmodalWarning(tr("No executable file to launch.")); - d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); - AnalyzerManager::stopTool(); - return false; - } - } - - if (d->m_runner) { - connect(d->m_runner, SIGNAL(stopped()), this, SLOT(notifyRemoteFinished())); - connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)), - this, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); - d->m_runner->start(); - d->m_noDebugOutputTimer.start(); - } else if (m_sp.startMode == StartQmlRemote) { + if (startParameters().startMode == StartLocal) { d->m_noDebugOutputTimer.start(); } else { emit processRunning(startParameters().analyzerPort); @@ -197,7 +131,7 @@ bool QmlProfilerEngine::start() return true; } -void QmlProfilerEngine::stop() +void QmlProfilerRunControl::stopEngine() { QTC_ASSERT(d->m_profilerState, return); @@ -222,7 +156,7 @@ void QmlProfilerEngine::stop() } } -void QmlProfilerEngine::notifyRemoteFinished(bool success) +void QmlProfilerRunControl::notifyRemoteFinished(bool success) { QTC_ASSERT(d->m_profilerState, return); @@ -234,7 +168,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success) d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled); AnalyzerManager::stopTool(); - engineFinished(); + runControlFinished(); break; } case QmlProfilerStateManager::AppStopped : @@ -250,7 +184,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success) } } -void QmlProfilerEngine::cancelProcess() +void QmlProfilerRunControl::cancelProcess() { QTC_ASSERT(d->m_profilerState, return); @@ -270,16 +204,16 @@ void QmlProfilerEngine::cancelProcess() return; } } - engineFinished(); + runControlFinished(); } -void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat format) +void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format) { - emit outputReceived(msg, format); + appendMessage(msg, format); d->m_outputParser.processOutput(msg); } -void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage) +void QmlProfilerRunControl::wrongSetupMessageBox(const QString &errorMessage) { QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow()); infoBox->setIcon(QMessageBox::Critical); @@ -299,10 +233,10 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage) // KILL d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying); AnalyzerManager::stopTool(); - emit finished(); + runControlFinished(); } -void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button) +void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button) { if (button == QMessageBox::Help) { Core::HelpManager *helpManager = Core::HelpManager::instance(); @@ -311,7 +245,7 @@ void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button) } } -void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg) +void QmlProfilerRunControl::showNonmodalWarning(const QString &warningMsg) { QMessageBox *noExecWarning = new QMessageBox(Core::ICore::mainWindow()); noExecWarning->setIcon(QMessageBox::Warning); @@ -323,27 +257,27 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg) noExecWarning->show(); } -void QmlProfilerEngine::notifyRemoteSetupDone(quint16 port) +void QmlProfilerRunControl::notifyRemoteSetupDone(quint16 port) { d->m_noDebugOutputTimer.stop(); emit processRunning(port); } -void QmlProfilerEngine::processIsRunning(quint16 port) +void QmlProfilerRunControl::processIsRunning(quint16 port) { d->m_noDebugOutputTimer.stop(); - if (port > 0 && mode() != StartQmlRemote) + if (port > 0 && startParameters().analyzerPort != 0) emit processRunning(port); } -void QmlProfilerEngine::engineStarted() +void QmlProfilerRunControl::engineStarted() { d->m_running = true; emit starting(this); } -void QmlProfilerEngine::engineFinished() +void QmlProfilerRunControl::runControlFinished() { d->m_running = false; emit finished(); @@ -351,7 +285,7 @@ void QmlProfilerEngine::engineFinished() //////////////////////////////////////////////////////////////// // Profiler State -void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *profilerState ) +void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManager *profilerState ) { // disconnect old if (d->m_profilerState) @@ -364,7 +298,7 @@ void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *p connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); } -void QmlProfilerEngine::profilerStateChanged() +void QmlProfilerRunControl::profilerStateChanged() { switch (d->m_profilerState->currentState()) { case QmlProfilerStateManager::AppReadyToStop : { diff --git a/plugins/qmlprofiler/qmlprofilerengine.h b/plugins/qmlprofiler/qmlprofilerengine.h index d4d28c93bd..cf0b476f9f 100644 --- a/plugins/qmlprofiler/qmlprofilerengine.h +++ b/plugins/qmlprofiler/qmlprofilerengine.h @@ -30,21 +30,22 @@ #ifndef QMLPROFILERENGINE_H #define QMLPROFILERENGINE_H -#include <analyzerbase/ianalyzerengine.h> #include "qmlprofilerstatemanager.h" + +#include <analyzerbase/analyzerruncontrol.h> #include <utils/outputformat.h> namespace QmlProfiler { namespace Internal { -class QmlProfilerEngine : public Analyzer::IAnalyzerEngine +class QmlProfilerRunControl : public Analyzer::AnalyzerRunControl { Q_OBJECT public: - QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, + QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration); - ~QmlProfilerEngine(); + ~QmlProfilerRunControl(); void registerProfilerStateManager( QmlProfilerStateManager *profilerState ); @@ -57,8 +58,8 @@ signals: void timeUpdate(); public slots: - bool start(); - void stop(); + bool startEngine(); + void stopEngine(); private slots: void notifyRemoteFinished(bool success = true); @@ -69,7 +70,7 @@ private slots: void wrongSetupMessageBoxFinished(int); void processIsRunning(quint16 port = 0); void engineStarted(); - void engineFinished(); + void runControlFinished(); private slots: void profilerStateChanged(); diff --git a/plugins/qmlprofiler/qmlprofilerplugin.cpp b/plugins/qmlprofiler/qmlprofilerplugin.cpp index 9cd725b39c..9cb1ee5ba6 100644 --- a/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -38,8 +38,6 @@ #include <QtPlugin> - - using namespace Analyzer; using namespace QmlProfiler; using namespace QmlProfiler::Internal; @@ -52,10 +50,9 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS Q_UNUSED(arguments) Q_UNUSED(errorString) - StartModes modes; - modes.append(StartMode(StartLocal)); - modes.append(StartMode(StartRemote)); - AnalyzerManager::addTool(new QmlProfilerTool(this), modes); + IAnalyzerTool *tool = new QmlProfilerTool(this); + AnalyzerManager::addTool(tool, StartLocal); + AnalyzerManager::addTool(tool, StartRemote); addAutoReleasedObject(new QmlProfilerRunControlFactory()); QmlProfilerPlugin::instance = this; diff --git a/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp index 6e3ab3ff6a..86f0583e81 100644 --- a/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp +++ b/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. @@ -37,11 +37,22 @@ #include <analyzerbase/analyzerruncontrol.h> #include <analyzerbase/analyzersettings.h> +#include <debugger/debuggerrunconfigurationaspect.h> + +#include <projectexplorer/environmentaspect.h> #include <projectexplorer/kitinformation.h> +#include <projectexplorer/localapplicationrunconfiguration.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/project.h> +#include <projectexplorer/session.h> #include <projectexplorer/target.h> +#include <qmlprojectmanager/qmlprojectrunconfiguration.h> + #include <utils/qtcassert.h> +#include <QTcpServer> + using namespace Analyzer; using namespace ProjectExplorer; @@ -55,35 +66,65 @@ QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) : bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const { - if (mode != QmlProfilerRunMode) - return false; - IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode); - if (tool) - return tool->canRun(runConfiguration, mode); - return false; + return mode == QmlProfilerRunMode + && (qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration) + || qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)); } -RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) +static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration *runConfiguration) { - IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode); - if (!tool) { - if (errorMessage) - *errorMessage = tr("No analyzer tool selected"); // never happens - return 0; + AnalyzerStartParameters sp; + EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>(); + + // FIXME: This is only used to communicate the connParams settings. + if (QmlProjectManager::QmlProjectRunConfiguration *rc1 = + qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)) { + // This is a "plain" .qmlproject. + if (environment) + sp.environment = environment->environment(); + sp.workingDirectory = rc1->workingDirectory(); + sp.debuggee = rc1->observerPath(); + sp.debuggeeArgs = rc1->viewerArguments(); + sp.displayName = rc1->displayName(); + } else if (LocalApplicationRunConfiguration *rc2 = + qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) { + if (environment) + sp.environment = environment->environment(); + sp.workingDirectory = rc2->workingDirectory(); + sp.debuggee = rc2->executable(); + sp.debuggeeArgs = rc2->commandLineArguments(); + sp.displayName = rc2->displayName(); + } else { + // What could that be? + QTC_ASSERT(false, return sp); + } + const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit()); + if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { + QTcpServer server; + if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) { + qWarning() << "Cannot open port on host for QML profiling."; + return sp; + } + sp.analyzerHost = server.serverAddress().toString(); + sp.analyzerPort = server.serverPort(); } + sp.startMode = StartLocal; + return sp; +} +RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) +{ QTC_ASSERT(canRun(runConfiguration, mode), return 0); - AnalyzerStartParameters sp = tool->createStartParameters(runConfiguration, mode); - sp.toolId = tool->id(); + AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration); + sp.runMode = mode; // only desktop device is supported - const ProjectExplorer::IDevice::ConstPtr device = - ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit()); + const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit()); QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0); - AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration); - QmlProfilerEngine *engine = qobject_cast<QmlProfilerEngine *>(rc->engine()); + AnalyzerRunControl *rc = AnalyzerManager::createRunControl(sp, runConfiguration); + QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc); if (!engine) { delete rc; return 0; @@ -94,7 +135,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat connect(runner, SIGNAL(stopped()), engine, SLOT(notifyRemoteFinished())); connect(runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)), engine, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); - connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)), runner, + connect(engine, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), runner, SLOT(start())); connect(rc, SIGNAL(finished()), runner, SLOT(stop())); return rc; diff --git a/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h b/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h index 3973411d93..46f2573df2 100644 --- a/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h +++ b/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. diff --git a/plugins/qmlprofiler/qmlprofilertool.cpp b/plugins/qmlprofiler/qmlprofilertool.cpp index 1ad954d51f..48c29616e9 100644 --- a/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/plugins/qmlprofiler/qmlprofilertool.cpp @@ -70,8 +70,6 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> -#include <debugger/debuggerrunconfigurationaspect.h> - #include <qtsupport/qtkitinformation.h> #include <QApplication> @@ -98,18 +96,12 @@ using namespace QmlProjectManager; class QmlProfilerTool::QmlProfilerToolPrivate { public: - QmlProfilerToolPrivate(QmlProfilerTool *qq) : q(qq) {} - ~QmlProfilerToolPrivate() {} - - QmlProfilerTool *q; - QmlProfilerStateManager *m_profilerState; QmlProfilerClientManager *m_profilerConnections; QmlProfilerModelManager *m_profilerModelManager; QmlProfilerViewManager *m_viewContainer; Utils::FileInProjectFinder m_projectFinder; - RunConfiguration *m_runConfiguration; QToolButton *m_recordButton; QToolButton *m_clearButton; @@ -124,13 +116,12 @@ public: }; QmlProfilerTool::QmlProfilerTool(QObject *parent) - : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this)) + : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate) { setObjectName(QLatin1String("QmlProfilerTool")); d->m_profilerState = 0; d->m_viewContainer = 0; - d->m_runConfiguration = 0; qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D"); qmlRegisterType<Context2D>(); @@ -206,10 +197,10 @@ IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const return AnyMode; } -IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp, +AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) { - QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration); + QmlProfilerRunControl *engine = new QmlProfilerRunControl(sp, runConfiguration); engine->registerProfilerStateManager(d->m_profilerState); @@ -236,15 +227,13 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp if (isTcpConnection) d->m_profilerConnections->setTcpConnection(sp.analyzerHost, sp.analyzerPort); - d->m_runConfiguration = runConfiguration; - // // Initialize m_projectFinder // QString projectDirectory; - if (d->m_runConfiguration) { - Project *project = d->m_runConfiguration->target()->project(); + if (runConfiguration) { + Project *project = runConfiguration->target()->project(); projectDirectory = project->projectDirectory(); } @@ -256,14 +245,6 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp return engine; } -bool QmlProfilerTool::canRun(RunConfiguration *runConfiguration, RunMode mode) const -{ - if (qobject_cast<QmlProjectRunConfiguration *>(runConfiguration) - || qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) - return mode == runMode(); - return false; -} - static QString sysroot(RunConfiguration *runConfig) { QTC_ASSERT(runConfig, return QString()); @@ -273,54 +254,6 @@ static QString sysroot(RunConfiguration *runConfig) return QString(); } -AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration *runConfiguration, RunMode mode) const -{ - Q_UNUSED(mode); - - AnalyzerStartParameters sp; - ProjectExplorer::EnvironmentAspect *environment - = runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>(); - Debugger::DebuggerRunConfigurationAspect *debugger - = runConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>(); - QTC_ASSERT(debugger, return sp); - - // FIXME: This is only used to communicate the connParams settings. - if (QmlProjectRunConfiguration *rc1 = - qobject_cast<QmlProjectRunConfiguration *>(runConfiguration)) { - // This is a "plain" .qmlproject. - if (environment) - sp.environment = environment->environment(); - sp.workingDirectory = rc1->workingDirectory(); - sp.debuggee = rc1->observerPath(); - sp.debuggeeArgs = rc1->viewerArguments(); - sp.displayName = rc1->displayName(); - } else if (LocalApplicationRunConfiguration *rc2 = - qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) { - if (environment) - sp.environment = environment->environment(); - sp.workingDirectory = rc2->workingDirectory(); - sp.debuggee = rc2->executable(); - sp.debuggeeArgs = rc2->commandLineArguments(); - sp.displayName = rc2->displayName(); - } else { - // What could that be? - QTC_ASSERT(false, return sp); - } - const ProjectExplorer::IDevice::ConstPtr device = - ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit()); - if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { - QTcpServer server; - if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) { - qWarning() << "Cannot open port on host for QML profiling."; - return sp; - } - sp.analyzerHost = server.serverAddress().toString(); - sp.analyzerPort = server.serverPort(); - } - sp.startMode = StartQml; - return sp; -} - QWidget *QmlProfilerTool::createWidgets() { QTC_ASSERT(!d->m_viewContainer, return 0); @@ -333,7 +266,6 @@ QWidget *QmlProfilerTool::createWidgets() connect(d->m_viewContainer, SIGNAL(gotoSourceLocation(QString,int,int)), this, SLOT(gotoSourceLocation(QString,int,int))); - // // Toolbar // @@ -513,7 +445,6 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode) } AnalyzerStartParameters sp; - sp.toolId = tool->id(); sp.startMode = mode; IDevice::ConstPtr device = DeviceKitInformation::device(kit); @@ -529,7 +460,8 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode) sp.sysroot = SysRootKitInformation::sysRoot(kit).toString(); sp.analyzerPort = port; - AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0); + //AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0); + AnalyzerRunControl *rc = tool->createRunControl(sp, 0); QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode()); @@ -597,8 +529,7 @@ void QmlProfilerTool::showLoadDialog() if (ModeManager::currentMode()->id() != MODE_ANALYZE) AnalyzerManager::showMode(); - if (AnalyzerManager::currentSelectedTool() != this) - AnalyzerManager::selectTool(this, StartRemote); + AnalyzerManager::selectTool(this, StartRemote); QString filename = QFileDialog::getOpenFileName(Core::ICore::mainWindow(), tr("Load QML Trace"), QString(), tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); diff --git a/plugins/qmlprofiler/qmlprofilertool.h b/plugins/qmlprofiler/qmlprofilertool.h index 412cb6a87f..5a3989e0e1 100644 --- a/plugins/qmlprofiler/qmlprofilertool.h +++ b/plugins/qmlprofiler/qmlprofilertool.h @@ -31,7 +31,7 @@ #define QMLPROFILERTOOL_H #include <analyzerbase/ianalyzertool.h> -#include <analyzerbase/ianalyzerengine.h> +#include <analyzerbase/analyzerruncontrol.h> QT_BEGIN_NAMESPACE class QMessageBox; @@ -56,16 +56,9 @@ public: void extensionsInitialized() {} - Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp, + Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration = 0); - bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; - - Analyzer::AnalyzerStartParameters createStartParameters( - ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; - QWidget *createWidgets(); void startTool(Analyzer::StartMode mode); |