From 666f3258ba0e6ed0b8068da32cc748b98383eaf2 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 10 Mar 2023 14:49:55 +0100 Subject: [PATCH] Docker: Fix shell exit handling Previously if a docker container was removed outside of Qt Creator the shell would not be correctly reset by the dockerdevice and therefor cause a hang. Change-Id: I5e84f7c114e525c732f45b701277736d6acc7a11 Reviewed-by: hjk Reviewed-by: --- src/libs/utils/deviceshell.cpp | 1 + src/plugins/docker/dockerdevice.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/deviceshell.cpp b/src/libs/utils/deviceshell.cpp index 283e9789c00..e8675745c08 100644 --- a/src/libs/utils/deviceshell.cpp +++ b/src/libs/utils/deviceshell.cpp @@ -98,6 +98,7 @@ RunResult DeviceShell::run(const CommandLine &cmd, const QByteArray &stdInData) const RunResult errorResult{-1, {}, {}}; QTC_ASSERT(m_shellProcess, return errorResult); + QTC_ASSERT(m_shellProcess->isRunning(), return errorResult); QTC_ASSERT(m_shellScriptState == State::Succeeded, return errorResult); QMutexLocker lk(&m_commandMutex); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 9ead5e8c783..e96ce9d6a47 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -679,12 +679,12 @@ void DockerDevicePrivate::startContainer() m_shell = std::make_unique(m_settings, m_container, q->rootPath()); connect(m_shell.get(), &DeviceShell::done, this, [this](const ProcessResultData &resultData) { + m_shell.release()->deleteLater(); if (resultData.m_error != QProcess::UnknownError || resultData.m_exitStatus == QProcess::NormalExit) return; qCWarning(dockerDeviceLog) << "Container shell encountered error:" << resultData.m_error; - m_shell.release()->deleteLater(); DockerApi::recheckDockerDaemon(); MessageManager::writeFlashing(Tr::tr("Docker daemon appears to be not running. "