aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/android/androiddevice.cpp
diff options
context:
space:
mode:
authorJarek Kobus <[email protected]>2022-03-14 22:12:21 +0100
committerJarek Kobus <[email protected]>2022-03-28 11:54:51 +0000
commit9f3941cda3443f6c3a3f2829b9c62081855e7a23 (patch)
tree886ddff713ef97d41611516a6773c03812efda2d /src/plugins/android/androiddevice.cpp
parentc8cee1a2341c41eff7b076ed35a11e80bfc23810 (diff)
AndroidDeviceManager: Remove the instance from plugin destructor
Delete the AndroidDeviceManager instance on shutdown from inside android plugin destructor. Implement AndroidDeviceManager destructor and wait for futures currently running to finish. Don't do any special handling for possibly still running m_adbDeviceWatcherProcess, as it will be deleted automatically by the std::unique_ptr and this will automatically initiate a proper termination of the process running. Change-Id: I5aad6f4fcfca23a0a37c3709efcdffad43a88203 Reviewed-by: <[email protected]> Reviewed-by: Assam Boudjelthia <[email protected]>
Diffstat (limited to 'src/plugins/android/androiddevice.cpp')
-rw-r--r--src/plugins/android/androiddevice.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp
index 6e6b83eef7e..c8534d1337f 100644
--- a/src/plugins/android/androiddevice.cpp
+++ b/src/plugins/android/androiddevice.cpp
@@ -836,10 +836,11 @@ void AndroidDeviceManager::HandleDevicesListChange(const QString &serialNumber)
}
}
+static AndroidDeviceManager *s_instance = nullptr;
+
AndroidDeviceManager *AndroidDeviceManager::instance()
{
- static AndroidDeviceManager obj;
- return &obj;
+ return s_instance;
}
AndroidDeviceManager::AndroidDeviceManager(QObject *parent)
@@ -847,18 +848,18 @@ 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);
+ QTC_ASSERT(!s_instance, return);
+ s_instance = this;
+}
+
+AndroidDeviceManager::~AndroidDeviceManager()
+{
+ m_avdsFutureWatcher.waitForFinished();
+ m_removeAvdFutureWatcher.waitForFinished();
+ QTC_ASSERT(s_instance == this, return);
+ s_instance = nullptr;
}
// Factory