From ec4fb84f8db02bfe2b0856924377689d608b6e0e Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 14 Apr 2022 13:02:16 +0200 Subject: [PATCH] LinuxDevice: Connect to QtcProcess::done() signal Instead of connecting to errorOccurred() and finished() signals. Change-Id: I939927b68e84b32455a914cef26200b4edcbcbb6 Reviewed-by: hjk --- src/plugins/remotelinux/linuxdevice.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 9a351441eb2..64746dc771c 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -333,17 +333,20 @@ LinuxDevice::LinuxDevice() setOpenTerminal([this](const Environment &env, const FilePath &workingDir) { QtcProcess * const proc = createProcess(nullptr); - QObject::connect(proc, &QtcProcess::finished, [proc] { - if (!proc->errorString().isEmpty()) { - Core::MessageManager::writeDisrupting( - tr("Error running remote shell: %1").arg(proc->errorString())); + QObject::connect(proc, &QtcProcess::done, [proc] { + if (proc->error() != QProcess::UnknownError) { + const QString errorString = proc->errorString(); + QString message; + if (proc->error() == QProcess::FailedToStart) + message = tr("Error starting remote shell."); + else if (errorString.isEmpty()) + message = tr("Error running remote shell."); + else + message = tr("Error running remote shell: %1").arg(errorString); + Core::MessageManager::writeDisrupting(message); } proc->deleteLater(); }); - QObject::connect(proc, &QtcProcess::errorOccurred, [proc] { - Core::MessageManager::writeDisrupting(tr("Error starting remote shell.")); - proc->deleteLater(); - }); // It seems we cannot pass an environment to OpenSSH dynamically // without specifying an executable.