diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp index 25ea819a422..0c1b29b46b6 100644 --- a/src/plugins/android/androiddevice.cpp +++ b/src/plugins/android/androiddevice.cpp @@ -478,7 +478,7 @@ expected_str AndroidDeviceManager::createAvd(const CreateAvdInfo &info, bo } }); - using namespace std::chrono_literals; + GuardLocker locker(m_avdPathGuard); process.runBlocking(); if (process.result() != ProcessResult::FinishedWithSuccess) return Utils::make_unexpected(process.exitMessage()); @@ -696,8 +696,10 @@ void AndroidDeviceManager::setupDevicesWatcher() const FilePath avdPath = FilePath::fromUserInput(avdEnvVar); m_avdFileSystemWatcher.addPath(avdPath.toString()); connect(&m_avdsFutureWatcher, &QFutureWatcherBase::finished, - this, &AndroidDeviceManager::HandleAvdsListChange); + this, &AndroidDeviceManager::HandleAvdsListChange); connect(&m_avdFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, [this] { + if (m_avdPathGuard.isLocked()) + return; // If the avd list upate command is running no need to call it again. if (!m_avdsFutureWatcher.isRunning()) updateAvdsList(); diff --git a/src/plugins/android/androiddevice.h b/src/plugins/android/androiddevice.h index 739e9c2753f..70729533f64 100644 --- a/src/plugins/android/androiddevice.h +++ b/src/plugins/android/androiddevice.h @@ -11,6 +11,8 @@ #include #include +#include + #include #include #include @@ -99,6 +101,7 @@ private: QFutureWatcher m_avdsFutureWatcher; std::unique_ptr m_removeAvdProcess; QFileSystemWatcher m_avdFileSystemWatcher; + Utils::Guard m_avdPathGuard; std::unique_ptr m_adbDeviceWatcherProcess; AndroidAvdManager m_avdManager;