summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2017-08-17 15:26:24 +0200
committerOliver Wolff <oliver.wolff@qt.io>2017-08-18 07:13:24 +0000
commit94cc2b914a027fbcb7a1eb6cb34af45d0c07d2a4 (patch)
treed0d46b0f9caa62061e257b9d8031c21c5e1c40cc /src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
parent687ec9eb370e9538264280b58bed4d3b1c889579 (diff)
winrt: Make sure that "finished" is emitted for device discovery
If we do not scan for low energy devices, the timeout will never be triggered. In this case the discovery is finished as soon as every paired device has been handled by the worker. Change-Id: I59772e706ac0fbf62c560a54d650bef9815118b6 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index 1aaaf0a4..17726660 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -104,7 +104,7 @@ private:
HRESULT onBluetoothLEDeviceFound(ComPtr<IBluetoothLEDevice> device, PairingCheck pairingCheck = CheckForPairing);
public slots:
- void handleLeTimeout();
+ void finishDiscovery();
Q_SIGNALS:
void deviceFound(const QBluetoothDeviceInfo &info);
@@ -247,7 +247,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::setupLEDeviceWatcher()
Q_ASSERT_SUCCEEDED(hr);
}
-void QWinRTBluetoothDeviceDiscoveryWorker::handleLeTimeout()
+void QWinRTBluetoothDeviceDiscoveryWorker::finishDiscovery()
{
emit scanFinished();
deleteLater();
@@ -263,6 +263,9 @@ void QWinRTBluetoothDeviceDiscoveryWorker::classicBluetoothInfoFromDeviceIdAsync
HRESULT hr = m_deviceStatics->FromIdAsync(deviceId, &deviceFromIdOperation);
if (FAILED(hr)) {
--m_pendingPairedDevices;
+ if (!m_pendingPairedDevices
+ && !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
+ finishDiscovery();
qCWarning(QT_BT_WINRT) << "Could not obtain bluetooth device from id";
return S_OK;
}
@@ -271,6 +274,9 @@ void QWinRTBluetoothDeviceDiscoveryWorker::classicBluetoothInfoFromDeviceIdAsync
(this, &QWinRTBluetoothDeviceDiscoveryWorker::onPairedClassicBluetoothDeviceFoundAsync).Get());
if (FAILED(hr)) {
--m_pendingPairedDevices;
+ if (!m_pendingPairedDevices
+ && !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
+ finishDiscovery();
qCWarning(QT_BT_WINRT) << "Could not register device found callback";
return S_OK;
}
@@ -386,6 +392,8 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onPairedClassicBluetoothDeviceFoun
QMetaObject::invokeMethod(this, "deviceFound", Qt::AutoConnection,
Q_ARG(QBluetoothDeviceInfo, info));
+ if (!m_pendingPairedDevices && !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
+ finishDiscovery();
return S_OK;
}
@@ -556,7 +564,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent
leScanTimer->setSingleShot(true);
}
connect(leScanTimer, &QTimer::timeout,
- worker, &QWinRTBluetoothDeviceDiscoveryWorker::handleLeTimeout);
+ worker, &QWinRTBluetoothDeviceDiscoveryWorker::finishDiscovery);
leScanTimer->setInterval(lowEnergySearchTimeout);
leScanTimer->start();
}
@@ -619,7 +627,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::disconnectAndClearWorker()
q, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered);
if (leScanTimer) {
disconnect(leScanTimer, &QTimer::timeout,
- worker, &QWinRTBluetoothDeviceDiscoveryWorker::handleLeTimeout);
+ worker, &QWinRTBluetoothDeviceDiscoveryWorker::finishDiscovery);
}
worker.clear();
}