diff options
author | Eike Ziller <[email protected]> | 2022-03-18 08:42:02 +0100 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2022-03-18 08:42:02 +0100 |
commit | e914f424589000d63e4a7b7f06429aeaba27a8f4 (patch) | |
tree | 3b4af6a70fb18b2165148ee4c1c9349fb1bf471e /src/plugins/android/androiddevice.cpp | |
parent | 5454dda2492f388f17e842f50e7c0731772c647f (diff) | |
parent | ab772c50be1bb6c5cac1ee6482c629b0cd530d0a (diff) |
Merge remote-tracking branch 'origin/7.0'
Change-Id: I9c4ef46084fd392663c7c21c4ecdbc578ea28577
Diffstat (limited to 'src/plugins/android/androiddevice.cpp')
-rw-r--r-- | src/plugins/android/androiddevice.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp index 8609fc7a89f..d0b782df442 100644 --- a/src/plugins/android/androiddevice.cpp +++ b/src/plugins/android/androiddevice.cpp @@ -35,6 +35,8 @@ #include <coreplugin/icore.h> +#include <extensionsystem/iplugin.h> + #include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/idevicewidget.h> #include <projectexplorer/kitinformation.h> @@ -588,6 +590,8 @@ void AndroidDeviceManager::setupDevicesWatcher() m_adbDeviceWatcherProcess->setCommand(command); m_adbDeviceWatcherProcess->setEnvironment(AndroidConfigurations::toolsEnvironment(m_androidConfig)); m_adbDeviceWatcherProcess->start(); + qCDebug(androidDeviceLog).noquote() << "ADB device watcher started:" + << command.toUserOutput(); // Setup AVD filesystem watcher to listen for changes when an avd is created/deleted, // or started/stopped @@ -611,6 +615,28 @@ 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(); @@ -764,16 +790,6 @@ AndroidDeviceManager::AndroidDeviceManager(QObject *parent) m_androidConfig(AndroidConfigurations::currentConfig()), m_avdManager(m_androidConfig) { - connect(qApp, &QCoreApplication::aboutToQuit, this, [this]() { - if (m_adbDeviceWatcherProcess) { - m_adbDeviceWatcherProcess->terminate(); - m_adbDeviceWatcherProcess->waitForFinished(); - m_adbDeviceWatcherProcess.reset(); - } - m_avdsFutureWatcher.waitForFinished(); - m_removeAvdFutureWatcher.waitForFinished(); - }); - connect(&m_removeAvdFutureWatcher, &QFutureWatcherBase::finished, this, &AndroidDeviceManager::handleAvdRemoved); } |