forked from qt-creator/qt-creator
ProjectExplorer: Use StandardRunnable in ApplicationLauncher
Change-Id: I7092d748207762d3dbd6c69c01cc06c88cbf63d8 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/applicationlauncher.h>
|
||||
#include <projectexplorer/runnables.h>
|
||||
|
||||
#include <qmljseditor/qmljseditorconstants.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
@@ -535,14 +536,17 @@ void QmlEngine::runEngine()
|
||||
void QmlEngine::startApplicationLauncher()
|
||||
{
|
||||
if (!d->applicationLauncher.isRunning()) {
|
||||
StandardRunnable runnable;
|
||||
runnable.environment = runParameters().inferiorEnvironment;
|
||||
runnable.workingDirectory = runParameters().workingDirectory;
|
||||
runnable.executable = runParameters().executable;
|
||||
runnable.commandLineArguments = runParameters().processArgs;
|
||||
appendMessage(tr("Starting %1 %2").arg(
|
||||
QDir::toNativeSeparators(runParameters().executable),
|
||||
runParameters().processArgs)
|
||||
QDir::toNativeSeparators(runnable.executable),
|
||||
runnable.commandLineArguments)
|
||||
+ QLatin1Char('\n')
|
||||
, Utils::NormalMessageFormat);
|
||||
d->applicationLauncher.start(ApplicationLauncher::Gui,
|
||||
runParameters().executable,
|
||||
runParameters().processArgs);
|
||||
d->applicationLauncher.start(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,9 +639,6 @@ void QmlEngine::setupEngine()
|
||||
// we need to get the port first
|
||||
notifyEngineRequestRemoteSetup();
|
||||
} else {
|
||||
d->applicationLauncher.setEnvironment(runParameters().inferiorEnvironment);
|
||||
d->applicationLauncher.setWorkingDirectory(runParameters().workingDirectory);
|
||||
|
||||
// We can't do this in the constructore because runControl() isn't yet defined
|
||||
connect(&d->applicationLauncher, &ApplicationLauncher::bringToForegroundRequested,
|
||||
runControl(), &RunControl::bringApplicationToForeground,
|
||||
|
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "projectexplorer.h"
|
||||
#include "projectexplorersettings.h"
|
||||
#include "runnables.h"
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::ApplicationLauncher
|
||||
@@ -134,44 +135,32 @@ ApplicationLauncher::~ApplicationLauncher()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ApplicationLauncher::setWorkingDirectory(const QString &dir)
|
||||
{
|
||||
// Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...)
|
||||
const QString fixedPath = Utils::FileUtils::normalizePathName(dir);
|
||||
d->m_guiProcess.setWorkingDirectory(fixedPath);
|
||||
d->m_consoleProcess.setWorkingDirectory(fixedPath);
|
||||
}
|
||||
|
||||
QString ApplicationLauncher::workingDirectory() const
|
||||
{
|
||||
return d->m_guiProcess.workingDirectory();
|
||||
}
|
||||
|
||||
void ApplicationLauncher::setEnvironment(const Utils::Environment &env)
|
||||
{
|
||||
d->m_guiProcess.setEnvironment(env);
|
||||
d->m_consoleProcess.setEnvironment(env);
|
||||
}
|
||||
|
||||
void ApplicationLauncher::setProcessChannelMode(QProcess::ProcessChannelMode mode)
|
||||
{
|
||||
d->m_guiProcess.setProcessChannelMode(mode);
|
||||
}
|
||||
|
||||
void ApplicationLauncher::start(Mode mode, const QString &program, const QString &args)
|
||||
void ApplicationLauncher::start(const StandardRunnable &runnable)
|
||||
{
|
||||
// Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...)
|
||||
const QString fixedPath = Utils::FileUtils::normalizePathName(runnable.workingDirectory);
|
||||
d->m_guiProcess.setWorkingDirectory(fixedPath);
|
||||
d->m_consoleProcess.setWorkingDirectory(fixedPath);
|
||||
d->m_guiProcess.setEnvironment(runnable.environment);
|
||||
d->m_consoleProcess.setEnvironment(runnable.environment);
|
||||
|
||||
d->m_processRunning = true;
|
||||
#ifdef Q_OS_WIN
|
||||
if (!WinDebugInterface::instance()->isRunning())
|
||||
WinDebugInterface::instance()->start(); // Try to start listener again...
|
||||
#endif
|
||||
|
||||
d->m_currentMode = mode;
|
||||
if (mode == Gui) {
|
||||
d->m_guiProcess.setCommand(program, args);
|
||||
d->m_currentMode = runnable.runMode;
|
||||
if (d->m_currentMode == Gui) {
|
||||
d->m_guiProcess.setCommand(runnable.executable, runnable.commandLineArguments);
|
||||
d->m_guiProcess.start();
|
||||
} else {
|
||||
d->m_consoleProcess.start(program, args);
|
||||
d->m_consoleProcess.start(runnable.executable, runnable.commandLineArguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,10 +32,10 @@
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
namespace Utils { class Environment; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
struct ApplicationLauncherPrivate;
|
||||
class StandardRunnable;
|
||||
|
||||
// Documentation inside.
|
||||
class PROJECTEXPLORER_EXPORT ApplicationLauncher : public QObject
|
||||
@@ -51,14 +51,8 @@ public:
|
||||
explicit ApplicationLauncher(QObject *parent = 0);
|
||||
~ApplicationLauncher();
|
||||
|
||||
void setWorkingDirectory(const QString &dir);
|
||||
QString workingDirectory() const;
|
||||
void setEnvironment(const Utils::Environment &env);
|
||||
|
||||
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
|
||||
|
||||
void start(Mode mode, const QString &program,
|
||||
const QString &args = QString());
|
||||
void start(const ProjectExplorer::StandardRunnable &runnable);
|
||||
void stop();
|
||||
bool isRunning() const;
|
||||
qint64 applicationPID() const;
|
||||
|
@@ -90,8 +90,7 @@ void LocalApplicationRunControl::start()
|
||||
m_running = true;
|
||||
QString msg = tr("Starting %1...").arg(QDir::toNativeSeparators(m_runnable.executable)) + QLatin1Char('\n');
|
||||
appendMessage(msg, Utils::NormalMessageFormat);
|
||||
m_applicationLauncher.setEnvironment(m_runnable.environment);
|
||||
m_applicationLauncher.start(m_runnable.runMode, m_runnable.executable, m_runnable.commandLineArguments);
|
||||
m_applicationLauncher.start(m_runnable);
|
||||
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/runnables.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/iprojectmanager.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
@@ -1071,11 +1072,6 @@ PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode)
|
||||
: RunControl(rc, mode), m_running(false)
|
||||
{
|
||||
setIcon(ProjectExplorer::Icons::RUN_SMALL);
|
||||
EnvironmentAspect *environment = rc->extraAspect<EnvironmentAspect>();
|
||||
Utils::Environment env;
|
||||
if (environment)
|
||||
env = environment->environment();
|
||||
m_applicationLauncher.setEnvironment(env);
|
||||
|
||||
m_interpreter = rc->interpreter();
|
||||
m_mainScript = rc->mainScript();
|
||||
@@ -1107,10 +1103,12 @@ void PythonRunControl::start()
|
||||
QString msg = tr("Starting %1...").arg(QDir::toNativeSeparators(m_interpreter)) + QLatin1Char('\n');
|
||||
appendMessage(msg, Utils::NormalMessageFormat);
|
||||
|
||||
QString args;
|
||||
QtcProcess::addArg(&args, m_mainScript);
|
||||
QtcProcess::addArgs(&args, m_commandLineArguments);
|
||||
m_applicationLauncher.start(m_runMode, m_interpreter, args);
|
||||
StandardRunnable r;
|
||||
QtcProcess::addArg(&r.commandLineArguments, m_mainScript);
|
||||
QtcProcess::addArgs(&r.commandLineArguments, m_commandLineArguments);
|
||||
r.executable = m_interpreter;
|
||||
r.runMode = m_runMode;
|
||||
m_applicationLauncher.start(r);
|
||||
|
||||
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
|
||||
}
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/runnables.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
@@ -46,8 +48,6 @@ QmlJSPreviewRunner::QmlJSPreviewRunner(QObject *parent) :
|
||||
+ Utils::HostOsInfo::pathListSeparator()
|
||||
+ QString::fromLocal8Bit(qgetenv("PATH"));
|
||||
m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer"));
|
||||
|
||||
m_applicationLauncher.setEnvironment(Utils::Environment::systemEnvironment());
|
||||
}
|
||||
|
||||
bool QmlJSPreviewRunner::isReady() const
|
||||
@@ -59,9 +59,12 @@ void QmlJSPreviewRunner::run(const QString &filename)
|
||||
{
|
||||
QString errorMessage;
|
||||
if (!filename.isEmpty()) {
|
||||
m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_qmlViewerDefaultPath,
|
||||
Utils::QtcProcess::quoteArg(filename));
|
||||
|
||||
ProjectExplorer::StandardRunnable r;
|
||||
r.environment = Utils::Environment::systemEnvironment();
|
||||
r.runMode = ProjectExplorer::ApplicationLauncher::Gui;
|
||||
r.executable = m_qmlViewerDefaultPath;
|
||||
r.commandLineArguments = Utils::QtcProcess::quoteArg(filename);
|
||||
m_applicationLauncher.start(r);
|
||||
} else {
|
||||
errorMessage = tr("No file specified.");
|
||||
}
|
||||
|
@@ -87,6 +87,7 @@ LocalQmlProfilerRunner::~LocalQmlProfilerRunner()
|
||||
|
||||
void LocalQmlProfilerRunner::start()
|
||||
{
|
||||
StandardRunnable runnable = m_configuration.debuggee;
|
||||
QString arguments = m_configuration.socket.isEmpty() ?
|
||||
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices,
|
||||
m_configuration.port) :
|
||||
@@ -97,18 +98,18 @@ void LocalQmlProfilerRunner::start()
|
||||
if (!m_configuration.debuggee.commandLineArguments.isEmpty())
|
||||
arguments += QLatin1Char(' ') + m_configuration.debuggee.commandLineArguments;
|
||||
|
||||
runnable.commandLineArguments = arguments;
|
||||
runnable.runMode = ApplicationLauncher::Gui;
|
||||
|
||||
if (QmlProfilerPlugin::debugOutput) {
|
||||
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.debuggee.workingDirectory);
|
||||
m_launcher.setEnvironment(m_configuration.debuggee.environment);
|
||||
connect(&m_launcher, &ApplicationLauncher::processExited,
|
||||
this, &LocalQmlProfilerRunner::spontaneousStop);
|
||||
m_launcher.start(ApplicationLauncher::Gui, m_configuration.debuggee.executable,
|
||||
arguments);
|
||||
m_launcher.start(runnable);
|
||||
|
||||
emit started();
|
||||
}
|
||||
|
@@ -76,11 +76,6 @@ void ValgrindProcess::setValgrindExecutable(const QString &valgrindExecutable)
|
||||
void ValgrindProcess::setDebuggee(const StandardRunnable &debuggee)
|
||||
{
|
||||
m_debuggee = debuggee;
|
||||
if (isLocal()) {
|
||||
m_localProcess.setWorkingDirectory(m_debuggee.workingDirectory);
|
||||
m_localProcess.setEnvironment(m_debuggee.environment);
|
||||
///TODO: remote anything that should/could be done here?
|
||||
}
|
||||
}
|
||||
|
||||
void ValgrindProcess::setValgrindArguments(const QStringList &valgrindArguments)
|
||||
@@ -122,8 +117,13 @@ void ValgrindProcess::run()
|
||||
connect(&m_localProcess, &ApplicationLauncher::appendMessage,
|
||||
this, &ValgrindProcess::processOutput);
|
||||
|
||||
m_localProcess.start(m_debuggee.runMode, m_valgrindExecutable,
|
||||
argumentString(Utils::HostOsInfo::hostOs()));
|
||||
StandardRunnable valgrind;
|
||||
valgrind.executable = m_valgrindExecutable;
|
||||
valgrind.runMode = m_debuggee.runMode;
|
||||
valgrind.commandLineArguments = argumentString(Utils::HostOsInfo::hostOs());
|
||||
valgrind.workingDirectory = m_debuggee.workingDirectory;
|
||||
valgrind.environment = m_debuggee.environment;
|
||||
m_localProcess.start(valgrind);
|
||||
|
||||
} else {
|
||||
// connect to host and wait for connection
|
||||
|
Reference in New Issue
Block a user