summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_osx.mm
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2017-10-11 10:10:27 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2017-10-11 09:38:33 +0000
commit4bce1481c5cfbd402973c2a488b36499ed44af2e (patch)
tree545541267438228eeb6ee3f7895f16df79a943b9 /src/bluetooth/qbluetoothsocket_osx.mm
parentcbf95d0ee78ad83cd26887670824e62678e4673e (diff)
IOBluetooth: warn about incorrent thread/runloop
IOBluetooth is heavily based on CFRunLoops. An attempt to use it on a thread, that does not properly run CFRunLoop results in callbacks never firing and thus QBluetooth classes never finishing their jobs, including: - device discovery - service discovery - RFCOMM/LCAP2 - Bluetooth server - Bluetooth socket etc. While we cannot fix the core problem until we have a properly working CoreFoundation event dispatcher, we can at least issue a warning so that people do not waste their time debugging this well-known limitation. Task-number: QTBUG-63630 Change-Id: Iefa4d675ea0962167bdfede640d2087dbdf37b18 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothsocket_osx.mm')
-rw-r--r--src/bluetooth/qbluetoothsocket_osx.mm8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_osx.mm
index 75712868..59fb66f2 100644
--- a/src/bluetooth/qbluetoothsocket_osx.mm
+++ b/src/bluetooth/qbluetoothsocket_osx.mm
@@ -443,6 +443,8 @@ qint64 QBluetoothSocket::bytesToWrite() const
void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, OpenMode openMode)
{
+ OSXBluetooth::qt_test_iobluetooth_runloop();
+
// Report this problem early, potentially avoid device discovery:
if (socketType() == QBluetoothServiceInfo::UnknownProtocol) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
@@ -480,6 +482,8 @@ void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, Op
void QBluetoothSocket::connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid,
OpenMode openMode)
{
+ OSXBluetooth::qt_test_iobluetooth_runloop();
+
// Report this problem early, avoid device discovery:
if (socketType() == QBluetoothServiceInfo::UnknownProtocol) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
@@ -505,6 +509,8 @@ void QBluetoothSocket::connectToService(const QBluetoothAddress &address, const
void QBluetoothSocket::connectToService(const QBluetoothAddress &address, quint16 port,
OpenMode openMode)
{
+ OSXBluetooth::qt_test_iobluetooth_runloop();
+
if (socketType() == QBluetoothServiceInfo::UnknownProtocol) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR);
@@ -571,6 +577,8 @@ void QBluetoothSocket::setSocketError(QBluetoothSocket::SocketError socketError)
void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, OpenMode openMode)
{
+ OSXBluetooth::qt_test_iobluetooth_runloop();
+
setSocketState(ServiceLookupState);
if (d_ptr->discoveryAgent)