diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-02-08 11:35:35 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-02-09 12:28:30 +0000 |
commit | ff68923846e30b8b23947c3a107d0e0aec3df4dc (patch) | |
tree | 61a0972070c0be3e7ccb73944d61728d2ff21e39 /src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp | |
parent | cfbf083089cf12c461980294f6e0df0bb856f10a (diff) |
Fix stopping the remote app run in terminal
It amends 9ec997b37654894b027cf4bbd98ca8bba47171b5
were in case of runInTerminal() we were not connected
to self started() signal anymore, so we were missing
a call to setState(SshDeviceProcessPrivate::ProcessRunning)
after start.
Amends 9ec997b37654894b027cf4bbd98ca8bba47171b5
Fixes: QTCREATORBUG-27014
Change-Id: I48bd2c223f36cd12b0b66bdc62f735b12cf7bdeb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp')
-rw-r--r-- | src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index 5d7d285e66..bf265b0258 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -51,7 +51,7 @@ public: SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {} SshDeviceProcess * const q; - bool ignoreFinished = true; + bool ignoreSelfSignals = true; QSsh::SshConnection *connection = nullptr; QSsh::SshRemoteProcessPtr remoteProcess; Runnable runnable; @@ -74,7 +74,17 @@ SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *par : DeviceProcess(device, QtcProcess::TerminalOn, parent), d(std::make_unique<SshDeviceProcessPrivate>(this)) { - connect(this, &QtcProcess::finished, this, &SshDeviceProcess::handleThisProcessFinished); + // Hack: we rely on fact that below slots were called before any other external slots connected + // to this instance signals. That's why we don't re-emit them from inside our handlers since + // these signal will reach all other external slots anyway after our handlers are done. + connect(this, &QtcProcess::started, this, [this] { + if (!d->ignoreSelfSignals) + handleProcessStarted(); + }); + connect(this, &QtcProcess::finished, this, [this] { + if (!d->ignoreSelfSignals) + handleProcessFinished(QtcProcess::errorString()); + }); connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout); } @@ -185,8 +195,8 @@ void SshDeviceProcess::handleConnected() const QString display = d->displayName(); if (!display.isEmpty()) d->remoteProcess->requestX11Forwarding(display); + d->ignoreSelfSignals = !runInTerminal(); if (runInTerminal()) { - d->ignoreFinished = false; setAbortOnMetaChars(false); setCommand(d->remoteProcess->fullLocalCommandLine(true)); QtcProcess::start(); @@ -194,7 +204,7 @@ void SshDeviceProcess::handleConnected() connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::started, this, &SshDeviceProcess::handleProcessStarted); connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done, - this, &SshDeviceProcess::handleRemoteProcessFinished); + this, &SshDeviceProcess::handleProcessFinished); connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput, this, &QtcProcess::readyReadStandardOutput); connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError, @@ -234,31 +244,17 @@ void SshDeviceProcess::handleProcessStarted() QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connected, return); d->setState(SshDeviceProcessPrivate::ProcessRunning); - emit started(); + if (d->ignoreSelfSignals) + emit started(); } -void SshDeviceProcess::handleThisProcessFinished() -{ - if (d->ignoreFinished) - return; - // Hack: we rely on fact that this slot was called before any other external slot connected - // to finished() signal. That's why we don't emit finished() signal from inside - // handleProcessFinished() since this signal will reach all other external slots anyway. - handleProcessFinished(QtcProcess::errorString(), false); -} - -void SshDeviceProcess::handleRemoteProcessFinished(const QString &error) -{ - handleProcessFinished(error, true); -} - -void SshDeviceProcess::handleProcessFinished(const QString &error, bool emitFinished) +void SshDeviceProcess::handleProcessFinished(const QString &error) { d->errorMessage = error; if (d->killOperation && error.isEmpty()) d->errorMessage = tr("The process was ended forcefully."); d->setState(SshDeviceProcessPrivate::Inactive); - if (emitFinished) + if (d->ignoreSelfSignals) emit finished(); } @@ -345,7 +341,6 @@ void SshDeviceProcess::SshDeviceProcessPrivate::setState(SshDeviceProcess::SshDe QMetaObject::invokeMethod(q, &QtcProcess::stopProcess, Qt::QueuedConnection); } killTimer.stop(); - ignoreFinished = true; if (remoteProcess) remoteProcess->disconnect(q); if (connection) { |