forked from qt-creator/qt-creator
Fix stopping the remote app run in terminal
It amends9ec997b376were 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. Amends9ec997b376Fixes: QTCREATORBUG-27014 Change-Id: I48bd2c223f36cd12b0b66bdc62f735b12cf7bdeb Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -51,7 +51,7 @@ public:
|
|||||||
SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {}
|
SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {}
|
||||||
|
|
||||||
SshDeviceProcess * const q;
|
SshDeviceProcess * const q;
|
||||||
bool ignoreFinished = true;
|
bool ignoreSelfSignals = true;
|
||||||
QSsh::SshConnection *connection = nullptr;
|
QSsh::SshConnection *connection = nullptr;
|
||||||
QSsh::SshRemoteProcessPtr remoteProcess;
|
QSsh::SshRemoteProcessPtr remoteProcess;
|
||||||
Runnable runnable;
|
Runnable runnable;
|
||||||
@@ -74,7 +74,17 @@ SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *par
|
|||||||
: DeviceProcess(device, QtcProcess::TerminalOn, parent),
|
: DeviceProcess(device, QtcProcess::TerminalOn, parent),
|
||||||
d(std::make_unique<SshDeviceProcessPrivate>(this))
|
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);
|
connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +195,8 @@ void SshDeviceProcess::handleConnected()
|
|||||||
const QString display = d->displayName();
|
const QString display = d->displayName();
|
||||||
if (!display.isEmpty())
|
if (!display.isEmpty())
|
||||||
d->remoteProcess->requestX11Forwarding(display);
|
d->remoteProcess->requestX11Forwarding(display);
|
||||||
|
d->ignoreSelfSignals = !runInTerminal();
|
||||||
if (runInTerminal()) {
|
if (runInTerminal()) {
|
||||||
d->ignoreFinished = false;
|
|
||||||
setAbortOnMetaChars(false);
|
setAbortOnMetaChars(false);
|
||||||
setCommand(d->remoteProcess->fullLocalCommandLine(true));
|
setCommand(d->remoteProcess->fullLocalCommandLine(true));
|
||||||
QtcProcess::start();
|
QtcProcess::start();
|
||||||
@@ -194,7 +204,7 @@ void SshDeviceProcess::handleConnected()
|
|||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::started,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::started,
|
||||||
this, &SshDeviceProcess::handleProcessStarted);
|
this, &SshDeviceProcess::handleProcessStarted);
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done,
|
||||||
this, &SshDeviceProcess::handleRemoteProcessFinished);
|
this, &SshDeviceProcess::handleProcessFinished);
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput,
|
||||||
this, &QtcProcess::readyReadStandardOutput);
|
this, &QtcProcess::readyReadStandardOutput);
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError,
|
||||||
@@ -234,31 +244,17 @@ void SshDeviceProcess::handleProcessStarted()
|
|||||||
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connected, return);
|
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connected, return);
|
||||||
|
|
||||||
d->setState(SshDeviceProcessPrivate::ProcessRunning);
|
d->setState(SshDeviceProcessPrivate::ProcessRunning);
|
||||||
|
if (d->ignoreSelfSignals)
|
||||||
emit started();
|
emit started();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshDeviceProcess::handleThisProcessFinished()
|
void SshDeviceProcess::handleProcessFinished(const QString &error)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
d->errorMessage = error;
|
d->errorMessage = error;
|
||||||
if (d->killOperation && error.isEmpty())
|
if (d->killOperation && error.isEmpty())
|
||||||
d->errorMessage = tr("The process was ended forcefully.");
|
d->errorMessage = tr("The process was ended forcefully.");
|
||||||
d->setState(SshDeviceProcessPrivate::Inactive);
|
d->setState(SshDeviceProcessPrivate::Inactive);
|
||||||
if (emitFinished)
|
if (d->ignoreSelfSignals)
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +341,6 @@ void SshDeviceProcess::SshDeviceProcessPrivate::setState(SshDeviceProcess::SshDe
|
|||||||
QMetaObject::invokeMethod(q, &QtcProcess::stopProcess, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(q, &QtcProcess::stopProcess, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
killTimer.stop();
|
killTimer.stop();
|
||||||
ignoreFinished = true;
|
|
||||||
if (remoteProcess)
|
if (remoteProcess)
|
||||||
remoteProcess->disconnect(q);
|
remoteProcess->disconnect(q);
|
||||||
if (connection) {
|
if (connection) {
|
||||||
|
|||||||
@@ -60,9 +60,7 @@ private:
|
|||||||
void handleConnectionError();
|
void handleConnectionError();
|
||||||
void handleDisconnected();
|
void handleDisconnected();
|
||||||
void handleProcessStarted();
|
void handleProcessStarted();
|
||||||
void handleThisProcessFinished();
|
void handleProcessFinished(const QString &error);
|
||||||
void handleRemoteProcessFinished(const QString &error);
|
|
||||||
void handleProcessFinished(const QString &error, bool emitFinished);
|
|
||||||
void handleKillOperationFinished(const QString &errorMessage);
|
void handleKillOperationFinished(const QString &errorMessage);
|
||||||
void handleKillOperationTimeout();
|
void handleKillOperationTimeout();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user