Fix closing remote linux applications

When the remote application was run in terminal it
was still marked as running in application output pane
after it has finished (the red square button was enabled).
This patch fixes it.

Stop the terminate timeout when stop was executed by user
(application output -> Stop running program) after
successful termination (so that instead of:
"Timeout waiting for remote process to finish."
we see now: "The process was ended forcefully.").

Fixes: QTCREATORBUG-26848
Change-Id: I2dfeccc60fb12388cb9dcfd56bd2aa2c5383209b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2022-01-14 16:01:34 +01:00
parent 5eafa345ed
commit 479c393009
3 changed files with 11 additions and 15 deletions

View File

@@ -462,12 +462,8 @@ void ApplicationLauncherPrivate::setFinished()
return;
int exitCode = 0;
if (m_deviceProcess) {
if (m_deviceProcess)
exitCode = m_deviceProcess->exitCode();
m_deviceProcess->disconnect(this);
m_deviceProcess->deleteLater();
m_deviceProcess = nullptr;
}
m_state = Inactive;
emit q->processExited(exitCode, m_remoteExitStatus);

View File

@@ -119,16 +119,14 @@ void SshDeviceProcess::interrupt()
void SshDeviceProcess::terminate()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);
d->doSignal(Signal::Terminate);
if (runInTerminal())
d->consoleProcess.stop();
}
void SshDeviceProcess::kill()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);
d->doSignal(Signal::Kill);
if (runInTerminal())
d->consoleProcess.stop();
}
QProcess::ProcessState SshDeviceProcess::state() const
@@ -199,6 +197,8 @@ void SshDeviceProcess::handleConnected()
this, &DeviceProcess::error);
connect(&d->consoleProcess, &ConsoleProcess::processStarted,
this, &SshDeviceProcess::handleProcessStarted);
connect(&d->consoleProcess, &ConsoleProcess::processStopped,
this, [this] { handleProcessFinished(d->consoleProcess.errorString()); });
connect(&d->consoleProcess, &ConsoleProcess::stubStopped,
this, [this] { handleProcessFinished(d->consoleProcess.errorString()); });
d->consoleProcess.setAbortOnMetaChars(false);
@@ -256,6 +256,8 @@ void SshDeviceProcess::handleProcessFinished(const QString &error)
{
d->errorMessage = error;
d->exitCode = runInTerminal() ? d->consoleProcess.exitCode() : d->process->exitCode();
if (d->killOperation && error.isEmpty())
d->errorMessage = tr("The process was ended forcefully.");
d->setState(SshDeviceProcessPrivate::Inactive);
emit finished();
}
@@ -357,6 +359,8 @@ void SshDeviceProcess::SshDeviceProcessPrivate::setState(SshDeviceProcess::SshDe
if (killOperation) {
killOperation->disconnect(q);
killOperation.clear();
if (q->runInTerminal())
QMetaObject::invokeMethod(&consoleProcess, &ConsoleProcess::stop, Qt::QueuedConnection);
}
killTimer.stop();
consoleProcess.disconnect();

View File

@@ -40,12 +40,8 @@ RemoteLinuxSignalOperation::RemoteLinuxSignalOperation(
RemoteLinuxSignalOperation::~RemoteLinuxSignalOperation()
{
if (m_runner) {
connect(m_runner, &QSsh::SshRemoteProcessRunner::processClosed,
m_runner, &QSsh::SshRemoteProcessRunner::deleteLater);
connect(m_runner, &QSsh::SshRemoteProcessRunner::connectionError,
m_runner, &QSsh::SshRemoteProcessRunner::deleteLater);
}
if (m_runner)
m_runner->deleteLater();
}
static QString signalProcessGroupByPidCommandLine(qint64 pid, int signal)