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