Commit 4d836596 authored by Joerg Bornemann's avatar Joerg Bornemann
Browse files

WinRt: detect devices when all prerequisites are loaded



Task-number: QTCREATORBUG-11928

Change-Id: I86ae446e01e3c1c7fe53df886428437f3eda7c18
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
parent f0fc3af0
......@@ -51,7 +51,17 @@ namespace Internal {
WinRtDeviceFactory::WinRtDeviceFactory()
: m_process(0)
, m_initialized(false)
{
if (allPrerequisitesLoaded()) {
onPrerequisitesLoaded();
} else {
connect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
connect(static_cast<QtVersionManager *>(QtVersionManager::instance()),
&QtVersionManager::qtVersionsLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
}
}
QString WinRtDeviceFactory::displayNameForId(Core::Id type) const
......@@ -107,13 +117,21 @@ void WinRtDeviceFactory::autoDetect()
m_process->start();
}
void WinRtDeviceFactory::onDevicesLoaded()
void WinRtDeviceFactory::onPrerequisitesLoaded()
{
if (!allPrerequisitesLoaded() || m_initialized)
return;
m_initialized = true;
disconnect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded);
QtVersionManager *qtVersionManager
= static_cast<QtVersionManager *>(QtVersionManager::instance());
disconnect(qtVersionManager, &QtVersionManager::qtVersionsLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded);
autoDetect();
connect(QtSupport::QtVersionManager::instance(),
SIGNAL(qtVersionsChanged(const QList<int>&, const QList<int>&,
const QList<int>&)),
SLOT(autoDetect()));
connect(qtVersionManager, &QtVersionManager::qtVersionsChanged,
this, &WinRtDeviceFactory::autoDetect);
}
void WinRtDeviceFactory::onProcessError()
......@@ -138,6 +156,11 @@ void WinRtDeviceFactory::onProcessFinished(int exitCode, QProcess::ExitStatus ex
parseRunnerOutput(m_process->readAllStandardOutput());
}
bool WinRtDeviceFactory::allPrerequisitesLoaded()
{
return QtVersionManager::isLoaded() && DeviceManager::instance()->isLoaded();
}
QString WinRtDeviceFactory::findRunnerFilePath() const
{
const QString winRtQtType = QLatin1String(Constants::WINRT_WINRTQT);
......
......@@ -50,17 +50,19 @@ public:
public slots:
void autoDetect();
void onDevicesLoaded();
void onPrerequisitesLoaded();
private slots:
void onProcessError();
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
static bool allPrerequisitesLoaded();
QString findRunnerFilePath() const;
void parseRunnerOutput(const QByteArray &output) const;
Utils::QtcProcess *m_process;
bool m_initialized;
};
} // Internal
......
......@@ -67,15 +67,7 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage
void WinRtPlugin::extensionsInitialized()
{
WinRtDeviceFactory *deviceFactory = new Internal::WinRtDeviceFactory;
addAutoReleasedObject(deviceFactory);
DeviceManager *deviceManager = DeviceManager::instance();
if (deviceManager->isLoaded()) {
deviceFactory->onDevicesLoaded();
} else {
connect(deviceManager, &DeviceManager::devicesLoaded,
deviceFactory, &WinRtDeviceFactory::onDevicesLoaded);
}
addAutoReleasedObject(new Internal::WinRtDeviceFactory);
}
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment