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 { ...@@ -51,7 +51,17 @@ namespace Internal {
WinRtDeviceFactory::WinRtDeviceFactory() WinRtDeviceFactory::WinRtDeviceFactory()
: m_process(0) : 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 QString WinRtDeviceFactory::displayNameForId(Core::Id type) const
...@@ -107,13 +117,21 @@ void WinRtDeviceFactory::autoDetect() ...@@ -107,13 +117,21 @@ void WinRtDeviceFactory::autoDetect()
m_process->start(); 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(); autoDetect();
connect(QtSupport::QtVersionManager::instance(), connect(qtVersionManager, &QtVersionManager::qtVersionsChanged,
SIGNAL(qtVersionsChanged(const QList<int>&, const QList<int>&, this, &WinRtDeviceFactory::autoDetect);
const QList<int>&)),
SLOT(autoDetect()));
} }
void WinRtDeviceFactory::onProcessError() void WinRtDeviceFactory::onProcessError()
...@@ -138,6 +156,11 @@ void WinRtDeviceFactory::onProcessFinished(int exitCode, QProcess::ExitStatus ex ...@@ -138,6 +156,11 @@ void WinRtDeviceFactory::onProcessFinished(int exitCode, QProcess::ExitStatus ex
parseRunnerOutput(m_process->readAllStandardOutput()); parseRunnerOutput(m_process->readAllStandardOutput());
} }
bool WinRtDeviceFactory::allPrerequisitesLoaded()
{
return QtVersionManager::isLoaded() && DeviceManager::instance()->isLoaded();
}
QString WinRtDeviceFactory::findRunnerFilePath() const QString WinRtDeviceFactory::findRunnerFilePath() const
{ {
const QString winRtQtType = QLatin1String(Constants::WINRT_WINRTQT); const QString winRtQtType = QLatin1String(Constants::WINRT_WINRTQT);
......
...@@ -50,17 +50,19 @@ public: ...@@ -50,17 +50,19 @@ public:
public slots: public slots:
void autoDetect(); void autoDetect();
void onDevicesLoaded(); void onPrerequisitesLoaded();
private slots: private slots:
void onProcessError(); void onProcessError();
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
private: private:
static bool allPrerequisitesLoaded();
QString findRunnerFilePath() const; QString findRunnerFilePath() const;
void parseRunnerOutput(const QByteArray &output) const; void parseRunnerOutput(const QByteArray &output) const;
Utils::QtcProcess *m_process; Utils::QtcProcess *m_process;
bool m_initialized;
}; };
} // Internal } // Internal
......
...@@ -67,15 +67,7 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage ...@@ -67,15 +67,7 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage
void WinRtPlugin::extensionsInitialized() void WinRtPlugin::extensionsInitialized()
{ {
WinRtDeviceFactory *deviceFactory = new Internal::WinRtDeviceFactory; addAutoReleasedObject(new Internal::WinRtDeviceFactory);
addAutoReleasedObject(deviceFactory);
DeviceManager *deviceManager = DeviceManager::instance();
if (deviceManager->isLoaded()) {
deviceFactory->onDevicesLoaded();
} else {
connect(deviceManager, &DeviceManager::devicesLoaded,
deviceFactory, &WinRtDeviceFactory::onDevicesLoaded);
}
} }
} // namespace Internal } // 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