summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Lemanissier <eric.lemanissier@gmail.com>2018-07-02 17:22:22 +0200
committerEric Lemanissier <eric.lemanissier@gmail.com>2018-07-23 17:31:34 +0000
commit5ec4a37bd3d3d13e6d5be918ca4c9f9979655af9 (patch)
treeb6077b07a6817ee5cfd72b3901f45edf70388a34
parent1286a7bc234b414b2bc9d57902bcb6a1d4c3e7ea (diff)
fix use of default constructed QBluetoothSocket
by checking the service passed to QBluetoothSocket::connectToService, instead of the previous protocol of the socket fixes up 21e7cb1bafdfc06c263e10067d02f9b103ff660f Change-Id: I2aa30cdd618f834e718508c5f492fc211d328565 (cherry picked from commit 150297f4884437ae22b03ed464313cd4d33088c1) Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp4
-rw-r--r--src/bluetooth/qbluetoothsocket_osx.mm16
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(),