-
Bug
-
Resolution: Done
-
P1: Critical
-
5.10.1
-
None
-
OS: Windows 10, version 1803
Compiler: msvc2017
There is a crash on Windows related with removing (unpair) a device from the system.
Unfortunately, currently, to work with a BLE device on Windows one need to pair a device in the system first.
Then if a device is removed from the system while in the same time one tries to connect to it with QLowEnergyController::connectToDevice (QLowEnergyController is in ConnectingState), there is a crash (preceeded with an assert).
ComPtr<IGattReadResult> result;
hr = QWinRTFunctions::await(op, result.GetAddressOf());
if (hr == E_INVALIDARG) {
// E_INVALIDARG happens when user tries to connect to a device that was paired
// before but is not available.
qCDebug(QT_BT_WINRT) << "Could not obtain characteristic read result that triggers"
"device connection. Is the device reachable?";
setError(QLowEnergyController::ConnectionError);
setState(QLowEnergyController::UnconnectedState);
return;
} else {
Q_ASSERT_SUCCEEDED(hr);
}
ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
hr = result->get_Value(&buffer);
The crash itself is in the line: hr = result->get_Value(&buffer);. For me it seems that a QWinRTFunctions::await function returns an error but different than E_INVALIDARG. Thus the assert in Q_ASSERT_SUCCEEDED. However, because the function is stil executed there is a try to use result which is not available.