forked from qt-creator/qt-creator
Android: Add locking mechanism when creating avd
Lock avd file system watcher changes when executing create avd command. Otherwise the avd file system watcher sends notifications during create avd command execution and subsequent avd list command doesn't report the device which is being added, yet. Change-Id: I1a0123d1bf14cf76e3a90e7f19416eb634e9c4a6 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -478,7 +478,7 @@ expected_str<void> AndroidDeviceManager::createAvd(const CreateAvdInfo &info, bo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
GuardLocker locker(m_avdPathGuard);
|
||||||
process.runBlocking();
|
process.runBlocking();
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return Utils::make_unexpected(process.exitMessage());
|
return Utils::make_unexpected(process.exitMessage());
|
||||||
@@ -696,8 +696,10 @@ void AndroidDeviceManager::setupDevicesWatcher()
|
|||||||
const FilePath avdPath = FilePath::fromUserInput(avdEnvVar);
|
const FilePath avdPath = FilePath::fromUserInput(avdEnvVar);
|
||||||
m_avdFileSystemWatcher.addPath(avdPath.toString());
|
m_avdFileSystemWatcher.addPath(avdPath.toString());
|
||||||
connect(&m_avdsFutureWatcher, &QFutureWatcherBase::finished,
|
connect(&m_avdsFutureWatcher, &QFutureWatcherBase::finished,
|
||||||
this, &AndroidDeviceManager::HandleAvdsListChange);
|
this, &AndroidDeviceManager::HandleAvdsListChange);
|
||||||
connect(&m_avdFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, [this] {
|
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 the avd list upate command is running no need to call it again.
|
||||||
if (!m_avdsFutureWatcher.isRunning())
|
if (!m_avdsFutureWatcher.isRunning())
|
||||||
updateAvdsList();
|
updateAvdsList();
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||||
|
|
||||||
|
#include <utils/guard.h>
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@@ -99,6 +101,7 @@ private:
|
|||||||
QFutureWatcher<AndroidDeviceInfoList> m_avdsFutureWatcher;
|
QFutureWatcher<AndroidDeviceInfoList> m_avdsFutureWatcher;
|
||||||
std::unique_ptr<Utils::Process> m_removeAvdProcess;
|
std::unique_ptr<Utils::Process> m_removeAvdProcess;
|
||||||
QFileSystemWatcher m_avdFileSystemWatcher;
|
QFileSystemWatcher m_avdFileSystemWatcher;
|
||||||
|
Utils::Guard m_avdPathGuard;
|
||||||
std::unique_ptr<Utils::Process> m_adbDeviceWatcherProcess;
|
std::unique_ptr<Utils::Process> m_adbDeviceWatcherProcess;
|
||||||
AndroidAvdManager m_avdManager;
|
AndroidAvdManager m_avdManager;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user