diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2021-12-20 12:20:12 +0100 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2022-02-11 14:26:07 +0200 |
commit | 475734595b4105e0972a58ef45d32d68b1d4125f (patch) | |
tree | 62dbfc642c3b3b9fb1c290f4ecb92d2bca1304d5 | |
parent | ca0c8f9f4a7ae9efab431eea38bca9f812af8751 (diff) |
IOBluetooth: tweak a couple of classes
1. Connection monitor: instead of asserting on 'monitor != nullptr' -
issue a warning and bail-out early. Despite of us unregistering from
connection notifications and trying to release the monitor,
IOBluetooth seems to keep references and sometimes it's possible to
trigger this assert in our autotests.
2. IOBluetoothDeviceInquiry - stop reporting errors completely, they are
not mapped to any error in QtBluetooth and give nothing but failing
auto-tests.
Change-Id: I8fc2e23d3685b912759df91c65b02537f39d1b5f
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
(cherry picked from commit ba38f64e22c98ba6b0d3bdccbd00ea5a643404f8)
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r-- | src/bluetooth/osx/osxbtconnectionmonitor.mm | 9 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtdeviceinquiry.mm | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/bluetooth/osx/osxbtconnectionmonitor.mm b/src/bluetooth/osx/osxbtconnectionmonitor.mm index bc955c75..811fa765 100644 --- a/src/bluetooth/osx/osxbtconnectionmonitor.mm +++ b/src/bluetooth/osx/osxbtconnectionmonitor.mm @@ -96,6 +96,15 @@ using namespace QT_NAMESPACE; if (!device) return; + if (!monitor) { + // Rather surprising: monitor == nullptr means we stopped monitoring. + // So apparently this thingie is still alive and keeps receiving + // notifications. + qCWarning(QT_BT_OSX, + "Connection notification received in a monitor that was cancelled"); + return; + } + QT_BT_MAC_AUTORELEASEPOOL; // All Obj-C objects are autoreleased. diff --git a/src/bluetooth/osx/osxbtdeviceinquiry.mm b/src/bluetooth/osx/osxbtdeviceinquiry.mm index 654effdc..6048a5c4 100644 --- a/src/bluetooth/osx/osxbtdeviceinquiry.mm +++ b/src/bluetooth/osx/osxbtdeviceinquiry.mm @@ -160,11 +160,11 @@ const uint8_t IOBlueoothInquiryLengthS = 15; if (error != kIOReturnSuccess && !aborted) { // QtBluetooth has not too many error codes, 'UnknownError' is not really - // useful, report the actual error code here: + // useful, log the actual error code here: qCWarning(QT_BT_OSX) << "IOKit error code: " << error; - m_delegate->error(error); // Let watchDog to stop it, calling -stop at timeout, otherwise, - // it looks like inquiry continues and keeps reporting new devices found. + // it looks like inquiry continues even after this error and + // keeps reporting new devices found. } else { // Either a normal completion or from a timer slot. watchDog.reset(); |