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