forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user