From 245f19122c2a6a112a35ee65556bcf00b6545d87 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 10 Oct 2019 15:15:53 +0200 Subject: qbluetoothdevicediscoveryagent_winrt: Decrement device count in case of failure It is possible that obtaining a paired device inside the callback fails, if the device was paired to another than the currently active bluetooth adapter. If we do not decrement the to be detected device count, the scan will never finish. Change-Id: I86140d082891482c759f33888b2483f3f5821253 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp index ae8e9184..30aa3fcc 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp @@ -440,8 +440,11 @@ void QWinRTBluetoothDeviceDiscoveryWorker::classicBluetoothInfoFromDeviceIdAsync hr = deviceFromIdOperation->put_Completed(Callback> ([thisPointer](IAsyncOperation *op, AsyncStatus status) { - if (status == Completed && thisPointer) - thisPointer->onPairedClassicBluetoothDeviceFoundAsync(op, status); + if (thisPointer) { + if (status == Completed) + thisPointer->onPairedClassicBluetoothDeviceFoundAsync(op, status); + --thisPointer->m_pendingPairedDevices; + } return S_OK; }).Get()); if (FAILED(hr)) { @@ -474,8 +477,11 @@ void QWinRTBluetoothDeviceDiscoveryWorker::leBluetoothInfoFromDeviceIdAsync(HSTR hr = deviceFromIdOperation->put_Completed(Callback> ([thisPointer] (IAsyncOperation *op, AsyncStatus status) { - if (status == Completed && thisPointer) - thisPointer->onPairedBluetoothLEDeviceFoundAsync(op, status); + if (thisPointer) { + if (status == Completed) + thisPointer->onPairedBluetoothLEDeviceFoundAsync(op, status); + --thisPointer->m_pendingPairedDevices; + } return S_OK; }).Get()); if (FAILED(hr)) { -- cgit v1.2.3