aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/qmlprofiler/qmlprofilerengine.cpp74
-rw-r--r--plugins/qmlprofiler/qmlprofilerengine.h3
-rw-r--r--plugins/qmlprofiler/qmlprofilertool.cpp2
3 files changed, 68 insertions, 11 deletions
diff --git a/plugins/qmlprofiler/qmlprofilerengine.cpp b/plugins/qmlprofiler/qmlprofilerengine.cpp
index f8f4058e5a..1127eb0d14 100644
--- a/plugins/qmlprofiler/qmlprofilerengine.cpp
+++ b/plugins/qmlprofiler/qmlprofilerengine.cpp
@@ -64,7 +64,8 @@ namespace Internal {
class QmlProfilerEngine::QmlProfilerEnginePrivate
{
public:
- QmlProfilerEnginePrivate(QmlProfilerEngine *qq, const AnalyzerStartParameters &sp) : q(qq), sp(sp), m_running(false) {}
+ QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {}
+ ~QmlProfilerEnginePrivate() { delete m_runner; }
bool attach(const QString &address, uint port);
@@ -74,20 +75,60 @@ public:
QTimer m_noDebugOutputTimer;
QmlDebug::QmlOutputParser m_outputParser;
- const AnalyzerStartParameters sp;
- 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(IAnalyzerTool *tool,
- const Analyzer::AnalyzerStartParameters &sp,
+QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
- : IAnalyzerEngine(tool, sp, runConfiguration)
- , d(new QmlProfilerEnginePrivate(this, sp))
+ : d(new QmlProfilerEnginePrivate(this))
{
+ 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
@@ -128,7 +169,24 @@ bool QmlProfilerEngine::start()
}
}
- if (d->sp.startMode == StartQmlRemote || d->sp.startMode == StartLocal) {
+ 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) {
d->m_noDebugOutputTimer.start();
} else {
emit processRunning(startParameters().analyzerPort);
diff --git a/plugins/qmlprofiler/qmlprofilerengine.h b/plugins/qmlprofiler/qmlprofilerengine.h
index aea3c8bf8d..d4d28c93bd 100644
--- a/plugins/qmlprofiler/qmlprofilerengine.h
+++ b/plugins/qmlprofiler/qmlprofilerengine.h
@@ -42,8 +42,7 @@ class QmlProfilerEngine : public Analyzer::IAnalyzerEngine
Q_OBJECT
public:
- QmlProfilerEngine(Analyzer::IAnalyzerTool *tool,
- const Analyzer::AnalyzerStartParameters &sp,
+ QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
~QmlProfilerEngine();
diff --git a/plugins/qmlprofiler/qmlprofilertool.cpp b/plugins/qmlprofiler/qmlprofilertool.cpp
index de8ffa5b47..1ad954d51f 100644
--- a/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -209,7 +209,7 @@ IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
- QmlProfilerEngine *engine = new QmlProfilerEngine(this, sp, runConfiguration);
+ QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration);
engine->registerProfilerStateManager(d->m_profilerState);