diff options
-rw-r--r-- | src/bluetooth/qbluetoothsocket.cpp | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_osx.mm | 16 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp index 2f38ed04..b02f8326 100644 --- a/src/bluetooth/qbluetoothsocket.cpp +++ b/src/bluetooth/qbluetoothsocket.cpp @@ -340,13 +340,13 @@ void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, Op #else #if defined(QT_WINRT_BLUETOOTH) // Report these problems early: - if (socketType() != QBluetoothServiceInfo::RfcommProtocol) { + if (service.socketProtocol() != QBluetoothServiceInfo::RfcommProtocol) { d->errorString = tr("Socket type not supported"); setSocketError(QBluetoothSocket::UnsupportedProtocolError); return; } #endif // QT_WINRT_BLUETOOTH - if (socketType() == QBluetoothServiceInfo::UnknownProtocol) { + if (service.socketProtocol() == QBluetoothServiceInfo::UnknownProtocol) { qCWarning(QT_BT) << "QBluetoothSocket::connectToService cannot " "connect with 'UnknownProtocol' type"; d->errorString = tr("Socket type not supported"); diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_osx.mm index 59fb66f2..ae5362e2 100644 --- a/src/bluetooth/qbluetoothsocket_osx.mm +++ b/src/bluetooth/qbluetoothsocket_osx.mm @@ -445,20 +445,22 @@ void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, Op { OSXBluetooth::qt_test_iobluetooth_runloop(); + if (state() != UnconnectedState && state() != ServiceLookupState) { + qCWarning(QT_BT_OSX) << "called on a busy socket"; + d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS); + setSocketError(OperationError); + return; + } + // Report this problem early, potentially avoid device discovery: - if (socketType() == QBluetoothServiceInfo::UnknownProtocol) { + if (service.socketProtocol() == QBluetoothServiceInfo::UnknownProtocol) { qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type"; d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR); setSocketError(QBluetoothSocket::UnsupportedProtocolError); return; } - if (state() != UnconnectedState && state() != ServiceLookupState) { - qCWarning(QT_BT_OSX) << "called on a busy socket"; - d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS); - setSocketError(OperationError); - return; - } + d_ptr->socketType = service.socketProtocol(); if (service.protocolServiceMultiplexer() > 0) { d_ptr->connectToService(service.device().address(), |