diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-06-13 17:11:00 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-06-14 14:07:47 +0000 |
commit | e00536eeea25e0ebbf44cf1af88eb7af916d8337 (patch) | |
tree | 8ddc3cd7bd2d1b098640e85b8dee6ee8d1533248 /src/plugins/remotelinux/linuxdevice.cpp | |
parent | 55eb0587ef65782561c8020801cad159e5dfe6e3 (diff) |
ProjectExplorer: Fix "Open Terminal With Run Env" for remote targets
Amends 6fa474ead8.
Note that the semantics of this operation are a bit dubious, because it
is supposed to open the terminal at the location of the file
corresponding to the project node, which does not make sense for remote
targets. So for those, we use the run configuration's working directory
instead.
Change-Id: Ie60b54e441daab51e8d51fdfba1d4a71e6a33604
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/remotelinux/linuxdevice.cpp')
-rw-r--r-- | src/plugins/remotelinux/linuxdevice.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index e6b22eb4bb..6e05739c01 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -196,9 +196,38 @@ LinuxDevice::LinuxDevice() } }}); + setOpenTerminal([this](const Utils::Environment &env, const QString &workingDir) { + 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; + runnable.workingDirectory = workingDir; + + // 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); + }); + if (Utils::HostOsInfo::isAnyUnixHost()) { addDeviceAction({tr("Open Remote Shell"), [](const IDevice::Ptr &device, QWidget *) { - device.staticCast<LinuxDevice>()->startRemoteShell(Utils::Environment()); + device->openTerminal(Utils::Environment(), QString()); }}); } } @@ -268,36 +297,6 @@ 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 { // Factory |