aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/android/androiddevice.cpp
diff options
context:
space:
mode:
authorEike Ziller <[email protected]>2022-03-18 08:42:02 +0100
committerEike Ziller <[email protected]>2022-03-18 08:42:02 +0100
commite914f424589000d63e4a7b7f06429aeaba27a8f4 (patch)
tree3b4af6a70fb18b2165148ee4c1c9349fb1bf471e /src/plugins/android/androiddevice.cpp
parent5454dda2492f388f17e842f50e7c0731772c647f (diff)
parentab772c50be1bb6c5cac1ee6482c629b0cd530d0a (diff)
Merge remote-tracking branch 'origin/7.0'
Diffstat (limited to 'src/plugins/android/androiddevice.cpp')
-rw-r--r--src/plugins/android/androiddevice.cpp36
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);
}