ProjectExplorer: Use Runnable in DeviceProcess::start

Change-Id: I8ce5b536745db11980f43449a055b7ebf9da83d2
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
hjk
2016-01-27 18:25:13 +01:00
parent 2a83564d62
commit 58be2708a3
22 changed files with 135 additions and 208 deletions

View File

@@ -26,6 +26,7 @@
#include "qnxdeviceprocess.h"
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
#include <projectexplorer/runnables.h>
#include <utils/qtcprocess.h>
using namespace ProjectExplorer;
@@ -39,14 +40,13 @@ static int pidFileCounter = 0;
QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent)
: SshDeviceProcess(device, parent)
{
setEnvironment(Environment(OsTypeLinux));
m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter);
}
QString QnxDeviceProcess::fullCommandLine() const
QString QnxDeviceProcess::fullCommandLine(const StandardRunnable &runnable) const
{
QStringList args = arguments();
args.prepend(executable());
QStringList args = QtcProcess::splitArgs(runnable.commandLineArguments);
args.prepend(runnable.executable);
QString cmd = QtcProcess::Arguments::createUnixArgs(args).toString();
QString fullCommandLine = QLatin1String(
@@ -54,10 +54,10 @@ QString QnxDeviceProcess::fullCommandLine() const
"test -f $HOME/profile && . $HOME/profile ; "
);
if (!m_workingDir.isEmpty())
fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(QtcProcess::quoteArg(m_workingDir));
if (!runnable.workingDirectory.isEmpty())
fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(QtcProcess::quoteArg(runnable.workingDirectory));
const Environment env = environment();
const Environment env = runnable.environment;
for (auto it = env.constBegin(); it != env.constEnd(); ++it)
fullCommandLine += QString::fromLatin1("%1='%2' ").arg(it.key()).arg(it.value());
@@ -69,9 +69,10 @@ QString QnxDeviceProcess::fullCommandLine() const
void QnxDeviceProcess::doSignal(int sig)
{
auto signaler = new SshDeviceProcess(device(), this);
QString cmd = QString::fromLatin1("kill -%2 `cat %1`").arg(m_pidFile).arg(sig);
StandardRunnable r;
r.executable = QString::fromLatin1("kill -%2 `cat %1`").arg(m_pidFile).arg(sig);
connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater);
signaler->start(cmd, QStringList());
signaler->start(r);
}
} // namespace Internal