diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-05-21 18:15:29 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-05-24 09:10:39 +0000 |
commit | 6fa474ead8cef352da73d4f02e4fd87971aa233e (patch) | |
tree | 695d205ca4d4344f48101df4d3a045cedec4054d /src/plugins/remotelinux/linuxdevice.cpp | |
parent | 0a555018d1dda0aafff358774af2b564483a8c1e (diff) |
Fix "open terminal with environment" functionality
... for RemoteLinux. We now open a *remote* terminal, as we should.
Change-Id: I84f73bbfcb6132717a30f5ef7c8d9d56d854a609
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/remotelinux/linuxdevice.cpp')
-rw-r--r-- | src/plugins/remotelinux/linuxdevice.cpp | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 6f5d8fb20a..e6b22eb4bb 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -44,6 +44,7 @@ #include <ssh/sshremoteprocessrunner.h> #include <utils/algorithm.h> +#include <utils/environment.h> #include <utils/hostosinfo.h> #include <utils/port.h> #include <utils/qtcassert.h> @@ -197,24 +198,7 @@ LinuxDevice::LinuxDevice() if (Utils::HostOsInfo::isAnyUnixHost()) { addDeviceAction({tr("Open Remote Shell"), [](const IDevice::Ptr &device, QWidget *) { - DeviceProcess * const proc = device->createProcess(nullptr); - QObject::connect(proc, &DeviceProcess::finished, [proc] { - if (!proc->errorString().isEmpty()) { - Core::MessageManager::write(tr("Error running remote shell: %1") - .arg(proc->errorString()), - Core::MessageManager::ModeSwitch); - } - proc->deleteLater(); - }); - QObject::connect(proc, &DeviceProcess::error, [proc] { - Core::MessageManager::write(tr("Error starting remote shell."), - Core::MessageManager::ModeSwitch); - proc->deleteLater(); - }); - Runnable runnable; - runnable.device = device; - proc->setRunInTerminal(true); - proc->start(runnable); + device.staticCast<LinuxDevice>()->startRemoteShell(Utils::Environment()); }}); } } @@ -284,6 +268,35 @@ bool LinuxDevice::supportsRSync() const return extraData("RemoteLinux.SupportsRSync").toBool(); } +void LinuxDevice::startRemoteShell(const Utils::Environment &env) const +{ + DeviceProcess * const proc = createProcess(nullptr); + QObject::connect(proc, &DeviceProcess::finished, [proc] { + if (!proc->errorString().isEmpty()) { + Core::MessageManager::write(tr("Error running remote shell: %1") + .arg(proc->errorString()), + Core::MessageManager::ModeSwitch); + } + proc->deleteLater(); + }); + QObject::connect(proc, &DeviceProcess::error, [proc] { + Core::MessageManager::write(tr("Error starting remote shell."), + Core::MessageManager::ModeSwitch); + proc->deleteLater(); + }); + Runnable runnable; + runnable.device = sharedFromThis(); + runnable.environment = env; + + // It seems we cannot pass an environment to OpenSSH dynamically + // without specifying an executable. + if (env.size() > 0) + runnable.executable = "/bin/sh"; + + proc->setRunInTerminal(true); + proc->start(runnable); +} + namespace Internal { |