winrt: Fix device watcher handling

When device watcher has been started it can have the enumerationComplete
state in addition to started. Hence only start the watcher if none of
those two states is present. This fixes an assert where starting an
already started watcher failed.

Change-Id: Idc3af256845f0993a26e8d186b499ef1c7e7dacc
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Maurice Kalinowski
2016-04-19 12:26:45 +02:00
parent a0a20157ef
commit a75f8fd0bb

View File

@@ -204,7 +204,8 @@ public:
DeviceWatcherStatus status;
hr = deviceWatcher->get_Status(&status);
Q_ASSERT_SUCCEEDED(hr);
if (status != DeviceWatcherStatus_Started) {
if (status != DeviceWatcherStatus_Started &&
status != DeviceWatcherStatus_EnumerationCompleted) {
// We can't immediately Start() if we have just called Stop()
while (status == DeviceWatcherStatus_Stopping) {
QThread::yieldCurrentThread();