From 78d90f1ec64fc7d588346c26d4270dc58c395e54 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 1 Dec 2014 15:00:49 +0100 Subject: QBluetoothLocalDevice - bug on OS X (isValid) If BT adapter is off local device is invalid on OS X: no way to access information like address/name, no way to turn the device on, all operations fail. Considering it's valid breaks the logic: you can pass any address to such a device (invalid non-null address) and device can not check if it's valid or not. Change-Id: I25f70723d566d4de8f993fc9c9a9e6867f936b7f Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothlocaldevice_osx.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/bluetooth/qbluetoothlocaldevice_osx.mm') diff --git a/src/bluetooth/qbluetoothlocaldevice_osx.mm b/src/bluetooth/qbluetoothlocaldevice_osx.mm index 38f15b8c..7e5cb12a 100644 --- a/src/bluetooth/qbluetoothlocaldevice_osx.mm +++ b/src/bluetooth/qbluetoothlocaldevice_osx.mm @@ -120,7 +120,11 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice QT_BT_MAC_AUTORELEASEPOOL; HostController defaultController([[IOBluetoothHostController defaultController] retain]); - if (!defaultController) { + if (!defaultController || [defaultController powerState] != kBluetoothHCIPowerStateON) { + // IOBluetooth can return non-null host controller without working adapter. + // Unfortunately, a local device in such a state is totally useless: + // you can not access any information like address/name or change the device + // state to powered on. So it's not valid. qCCritical(QT_BT_OSX) << "QBluetoothLocalDevicePrivate(), failed to " "init a host controller object"; return; -- cgit v1.2.3