summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-03-14 22:12:21 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-03-23 09:33:20 +0000
commit816746a06ddf95cba8575edf9664aee23eba07b1 (patch)
treec2d862a0130ace4a080cc124e2a31f6c383bfc6f
parentfaadc86ecea22c668ef32d4dc42210cc87d8262e (diff)
downloadqt-creator-816746a06ddf95cba8575edf9664aee23eba07b1.tar.gz
LauncherInterface: Wait for graceful finish of process launcher
Give process launcher a chance to finish its processes gracefully before we finish process launcher's process in Creator. Otherwise, when Creator's process reaper kills the process launcher's process while the process launcher is still reaping its processes, the process launcher may leave zombies. Instantiate the ProcessReaper inside ProcessReaper::reap(), otherwise its destructor won't run at all inside process launcher. Reverts e45e16d904f704920bd457fdf3302f3ae7061459 Fixes: QTCREATORBUG-27118 Change-Id: I00290cda05538b5a7ecbeb08240d1e3772d43d62 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/libs/utils/launcherinterface.cpp9
-rw-r--r--src/libs/utils/processreaper.cpp1
-rw-r--r--src/plugins/android/androiddevice.cpp31
-rw-r--r--src/plugins/android/androiddevice.h7
-rw-r--r--src/plugins/android/androidplugin.cpp13
-rw-r--r--src/plugins/android/androidplugin.h2
6 files changed, 16 insertions, 47 deletions
diff --git a/src/libs/utils/launcherinterface.cpp b/src/libs/utils/launcherinterface.cpp
index a77650745a..08c9312465 100644
--- a/src/libs/utils/launcherinterface.cpp
+++ b/src/libs/utils/launcherinterface.cpp
@@ -138,12 +138,11 @@ void LauncherInterfacePrivate::doStart()
void LauncherInterfacePrivate::doStop()
{
m_server->close();
- if (!m_process)
- return;
- m_process->disconnect();
+ QTC_ASSERT(m_process, return);
m_socket->shutdown();
- m_process->waitForFinished(3000);
- ProcessReaper::reap(m_process);
+ m_process->waitForFinished(-1); // Let the process interface finish so that it finishes
+ // reaping any possible processes it has started.
+ delete m_process;
m_process = nullptr;
}
diff --git a/src/libs/utils/processreaper.cpp b/src/libs/utils/processreaper.cpp
index 076981573d..3ff060be54 100644
--- a/src/libs/utils/processreaper.cpp
+++ b/src/libs/utils/processreaper.cpp
@@ -195,6 +195,7 @@ void ProcessReaper::reap(QProcess *process, int timeoutMs)
return;
}
+ ProcessReaper::instance();
new Internal::Reaper(process, timeoutMs);
}
diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp
index dac30fd144..1839d16f56 100644
--- a/src/plugins/android/androiddevice.cpp
+++ b/src/plugins/android/androiddevice.cpp
@@ -35,8 +35,6 @@
#include <coreplugin/icore.h>
-#include <extensionsystem/iplugin.h>
-
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/devicesupport/idevicewidget.h>
#include <projectexplorer/kitinformation.h>
@@ -621,28 +619,6 @@ void AndroidDeviceManager::setupDevicesWatcher()
updateAvdsList();
}
-void AndroidDeviceManager::shutdownDevicesWatcher()
-{
- m_avdsFutureWatcher.waitForFinished();
- m_removeAvdFutureWatcher.waitForFinished();
-
- if (m_adbDeviceWatcherProcess) {
- m_adbDeviceWatcherProcess->terminate();
- m_adbDeviceWatcherProcess->waitForFinished();
- m_adbDeviceWatcherProcess.reset();
-
- // Despite terminate/waitForFinished, the process may still
- // be around and remain if Qt Creator finishes too early.
- QTimer::singleShot(1000, this, [this] { emit devicesWatcherShutdownFinished(); });
- }
-}
-
-ExtensionSystem::IPlugin::ShutdownFlag AndroidDeviceManager::devicesShutdownFlag() const
-{
- return m_adbDeviceWatcherProcess ? ExtensionSystem::IPlugin::AsynchronousShutdown
- : ExtensionSystem::IPlugin::SynchronousShutdown;
-}
-
void AndroidDeviceManager::HandleAvdsListChange()
{
DeviceManager *const devMgr = DeviceManager::instance();
@@ -706,6 +682,13 @@ void AndroidDeviceManager::HandleAvdsListChange()
}
}
+void AndroidDeviceManager::shutdownDevicesWatcher()
+{
+ m_avdsFutureWatcher.waitForFinished();
+ m_removeAvdFutureWatcher.waitForFinished();
+ m_adbDeviceWatcherProcess.reset();
+}
+
void AndroidDeviceManager::HandleDevicesListChange(const QString &serialNumber)
{
DeviceManager *const devMgr = DeviceManager::instance();
diff --git a/src/plugins/android/androiddevice.h b/src/plugins/android/androiddevice.h
index 5ecf8101e0..9800098fb1 100644
--- a/src/plugins/android/androiddevice.h
+++ b/src/plugins/android/androiddevice.h
@@ -30,8 +30,6 @@
#include "androidconfigurations.h"
#include "androiddeviceinfo.h"
-#include <extensionsystem/iplugin.h>
-
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
@@ -106,7 +104,7 @@ public:
static AndroidDeviceManager *instance();
void setupDevicesWatcher();
void shutdownDevicesWatcher();
- ExtensionSystem::IPlugin::ShutdownFlag devicesShutdownFlag() const;
+
void updateAvdsList();
IDevice::DeviceState getDeviceState(const QString &serial, IDevice::MachineType type) const;
void updateDeviceState(const ProjectExplorer::IDevice::ConstPtr &device);
@@ -118,9 +116,6 @@ public:
QString getRunningAvdsSerialNumber(const QString &name) const;
-signals:
- void devicesWatcherShutdownFinished();
-
private:
AndroidDeviceManager(QObject *parent = nullptr);
void HandleDevicesListChange(const QString &serialNumber);
diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp
index bda2f80587..7eb8e8c0d2 100644
--- a/src/plugins/android/androidplugin.cpp
+++ b/src/plugins/android/androidplugin.cpp
@@ -160,17 +160,10 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
return true;
}
-AndroidPlugin::ShutdownFlag AndroidPlugin::aboutToShutdown()
+ExtensionSystem::IPlugin::ShutdownFlag AndroidPlugin::aboutToShutdown()
{
- AndroidDeviceManager *dm = AndroidDeviceManager::instance();
- const IPlugin::ShutdownFlag sf = dm->devicesShutdownFlag();
-
- if (sf == AsynchronousShutdown)
- connect(dm, &AndroidDeviceManager::devicesWatcherShutdownFinished,
- this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
-
- dm->shutdownDevicesWatcher();
- return sf;
+ AndroidDeviceManager::instance()->shutdownDevicesWatcher();
+ return ExtensionSystem::IPlugin::SynchronousShutdown;
}
void AndroidPlugin::kitsRestored()
diff --git a/src/plugins/android/androidplugin.h b/src/plugins/android/androidplugin.h
index 3d46ca0867..e98a5a32cd 100644
--- a/src/plugins/android/androidplugin.h
+++ b/src/plugins/android/androidplugin.h
@@ -44,9 +44,7 @@ class AndroidPlugin final : public ExtensionSystem::IPlugin
class AndroidPluginPrivate *d = nullptr;
-public:
ShutdownFlag aboutToShutdown() final;
-
#ifdef WITH_TESTS
private slots:
void testAndroidSdkManagerProgressParser_data();