diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index be3b2ac7805..c342af3b726 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -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, diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 5affb04d7fa..1956734bf7a 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -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); } } diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index 67e5b679d72..da3b2586402 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -32,10 +32,10 @@ #include -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; diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index b12540d1120..4985141e696 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -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())); } } diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index e1f5a5e01f6..f97c77ff2c0 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -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(); - 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())); } diff --git a/src/plugins/qmljseditor/qmljspreviewrunner.cpp b/src/plugins/qmljseditor/qmljspreviewrunner.cpp index 657363176b6..31b9270eb4f 100644 --- a/src/plugins/qmljseditor/qmljspreviewrunner.cpp +++ b/src/plugins/qmljseditor/qmljspreviewrunner.cpp @@ -27,6 +27,8 @@ #include +#include + #include #include #include @@ -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."); } diff --git a/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp b/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp index 2bc4b5e360a..7492ce0ff15 100644 --- a/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp +++ b/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp @@ -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(); } diff --git a/src/plugins/valgrind/valgrindprocess.cpp b/src/plugins/valgrind/valgrindprocess.cpp index 5604fbb4083..34f3c8ee31e 100644 --- a/src/plugins/valgrind/valgrindprocess.cpp +++ b/src/plugins/valgrind/valgrindprocess.cpp @@ -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