forked from qt-creator/qt-creator
QmlProfiler: Use StandardRunnable in LocalQmlProfilerRunner
Change-Id: I8c59f9dfe562717edd86453b0154b7f2811a06f3 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -66,8 +66,7 @@ quint16 LocalQmlProfilerRunner::findFreePort(QString &host)
|
||||
LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration,
|
||||
QmlProfilerRunControl *engine) :
|
||||
QObject(engine),
|
||||
m_configuration(configuration),
|
||||
m_engine(engine)
|
||||
m_configuration(configuration)
|
||||
{
|
||||
connect(&m_launcher, &ApplicationLauncher::appendMessage,
|
||||
this, &LocalQmlProfilerRunner::appendMessage);
|
||||
@@ -95,20 +94,21 @@ void LocalQmlProfilerRunner::start()
|
||||
m_configuration.socket);
|
||||
|
||||
|
||||
if (!m_configuration.executableArguments.isEmpty())
|
||||
arguments += QLatin1Char(' ') + m_configuration.executableArguments;
|
||||
if (!m_configuration.debuggee.commandLineArguments.isEmpty())
|
||||
arguments += QLatin1Char(' ') + m_configuration.debuggee.commandLineArguments;
|
||||
|
||||
if (QmlProfilerPlugin::debugOutput) {
|
||||
qWarning("QmlProfiler: Launching %s:%s", qPrintable(m_configuration.executable),
|
||||
qWarning("QmlProfiler: Launching %s:%s", qPrintable(m_configuration.debuggee.executable),
|
||||
qPrintable(m_configuration.socket.isEmpty() ?
|
||||
QString::number(m_configuration.port) : m_configuration.socket));
|
||||
}
|
||||
|
||||
m_launcher.setWorkingDirectory(m_configuration.workingDirectory);
|
||||
m_launcher.setEnvironment(m_configuration.environment);
|
||||
m_launcher.setWorkingDirectory(m_configuration.debuggee.workingDirectory);
|
||||
m_launcher.setEnvironment(m_configuration.debuggee.environment);
|
||||
connect(&m_launcher, &ApplicationLauncher::processExited,
|
||||
this, &LocalQmlProfilerRunner::spontaneousStop);
|
||||
m_launcher.start(ApplicationLauncher::Gui, m_configuration.executable, arguments);
|
||||
m_launcher.start(ApplicationLauncher::Gui, m_configuration.debuggee.executable,
|
||||
arguments);
|
||||
|
||||
emit started();
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "qmlprofiler_global.h"
|
||||
#include <utils/environment.h>
|
||||
#include <projectexplorer/applicationlauncher.h>
|
||||
#include <projectexplorer/runnables.h>
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
@@ -39,12 +40,9 @@ class QMLPROFILER_EXPORT LocalQmlProfilerRunner : public QObject
|
||||
|
||||
public:
|
||||
struct Configuration {
|
||||
QString executable;
|
||||
QString executableArguments;
|
||||
ProjectExplorer::StandardRunnable debuggee;
|
||||
quint16 port;
|
||||
QString socket;
|
||||
QString workingDirectory;
|
||||
Utils::Environment environment;
|
||||
};
|
||||
|
||||
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
|
||||
@@ -65,7 +63,6 @@ private:
|
||||
|
||||
Configuration m_configuration;
|
||||
ProjectExplorer::ApplicationLauncher m_launcher;
|
||||
QmlProfilerRunControl *m_engine;
|
||||
};
|
||||
|
||||
} // namespace QmlProfiler
|
||||
|
@@ -75,6 +75,12 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
|
||||
QTC_ASSERT(runConfiguration->runnable().is<StandardRunnable>(), return 0);
|
||||
auto runnable = runConfiguration->runnable().as<StandardRunnable>();
|
||||
|
||||
if (runnable.executable.isEmpty()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("No executable file to launch.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Kit *kit = runConfiguration->target()->kit();
|
||||
AnalyzerConnection connection;
|
||||
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
||||
@@ -101,20 +107,10 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
|
||||
runControl->setConnection(connection);
|
||||
|
||||
LocalQmlProfilerRunner::Configuration conf;
|
||||
conf.executable = runnable.executable;
|
||||
conf.executableArguments = runnable.commandLineArguments;
|
||||
conf.workingDirectory = runnable.workingDirectory;
|
||||
conf.debuggee = runnable;
|
||||
conf.socket = connection.analyzerSocket;
|
||||
if (EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>())
|
||||
conf.environment = environment->environment();
|
||||
conf.port = connection.analyzerPort;
|
||||
|
||||
if (conf.executable.isEmpty()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("No executable file to launch.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void) new LocalQmlProfilerRunner(conf, runControl);
|
||||
return runControl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user