summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java39
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp18
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp2
-rw-r--r--src/bluetooth/qbluetoothsocket_android.cpp1
-rw-r--r--src/bluetooth/qbluetoothsocket_osx.mm3
5 files changed, 44 insertions, 19 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
index 1b527ae3..4063537b 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
@@ -1141,16 +1141,24 @@ public class QtBluetoothLE {
if (handle == HANDLE_FOR_MTU_EXCHANGE)
return;
- GattEntry entry = entries.get(handle);
- if (entry == null)
- return;
- if (entry.valueKnown)
- return;
- entry.valueKnown = true;
+ try {
+ synchronized (this) {
- GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
- if (serviceEntry != null && serviceEntry.endHandle == handle)
- finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ GattEntry entry = entries.get(handle);
+ if (entry == null)
+ return;
+ if (entry.valueKnown)
+ return;
+ entry.valueKnown = true;
+
+ GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
+ if (serviceEntry != null && serviceEntry.endHandle == handle)
+ finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ }
+ } catch (IndexOutOfBoundsException outOfBounds) {
+ Log.w(TAG, "interruptCurrentIO(): Unknown gatt entry, index: "
+ + handle + " size: " + entries.size());
+ }
}
/*
@@ -1271,9 +1279,16 @@ public class QtBluetoothLE {
}
// last entry of current discovery run?
- GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
- if (serviceEntry.endHandle == handle)
- finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ synchronized (this) {
+ try {
+ GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
+ if (serviceEntry.endHandle == handle)
+ finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ } catch (IndexOutOfBoundsException outOfBounds) {
+ Log.w(TAG, "performNextIO(): Unknown service for entry, index: "
+ + entry.associatedServiceHandle + " size: " + entries.size());
+ }
+ }
} else {
int errorCode = 0;
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index 4eb3ca58..c247f679 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -529,16 +529,20 @@ void QBluetoothLocalDevicePrivate::processPairingBluez5(const QString &objectPat
switch (target) {
case QBluetoothLocalDevice::Unpaired: {
delete pairingTarget;
- pairingTarget = 0;
+ pairingTarget = nullptr;
QDBusPendingReply<> removeReply = adapterBluez5->RemoveDevice(QDBusObjectPath(objectPath));
- removeReply.waitForFinished();
-
- if (removeReply.isError())
- emit q->error(QBluetoothLocalDevice::PairingError);
- else
- emit q->pairingFinished(targetAddress, QBluetoothLocalDevice::Unpaired);
+ auto watcher = new QDBusPendingCallWatcher(removeReply, this);
+ connect(watcher, &QDBusPendingCallWatcher::finished,
+ this, [q, targetAddress](QDBusPendingCallWatcher* watcher){
+ QDBusPendingReply<> reply = *watcher;
+ if (reply.isError())
+ emit q->error(QBluetoothLocalDevice::PairingError);
+ else
+ emit q->pairingFinished(targetAddress, QBluetoothLocalDevice::Unpaired);
+ watcher->deleteLater();
+ });
break;
}
case QBluetoothLocalDevice::Paired:
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index c5b0f7d3..1ad3ffc2 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -742,6 +742,7 @@ void QBluetoothSocket::abort()
#ifndef QT_ANDROID_BLUETOOTH
//Android closes when the Java event loop comes around
setSocketState(QBluetoothSocket::UnconnectedState);
+ emit readChannelFinished();
emit disconnected();
#endif
}
@@ -827,6 +828,7 @@ void QBluetoothSocket::close()
#ifndef QT_ANDROID_BLUETOOTH
//Android closes when the Java event loop comes around
setSocketState(UnconnectedState);
+ emit readChannelFinished();
emit disconnected();
#endif
}
diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp
index d0b901ae..a70b95a2 100644
--- a/src/bluetooth/qbluetoothsocket_android.cpp
+++ b/src/bluetooth/qbluetoothsocket_android.cpp
@@ -779,6 +779,7 @@ void QBluetoothSocketPrivate::inputThreadError(int errorCode)
q->setSocketState(QBluetoothSocket::UnconnectedState);
q->setOpenMode(QIODevice::NotOpen);
+ emit q->readChannelFinished();
emit q->disconnected();
}
diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_osx.mm
index de7e2120..dec542dd 100644
--- a/src/bluetooth/qbluetoothsocket_osx.mm
+++ b/src/bluetooth/qbluetoothsocket_osx.mm
@@ -351,6 +351,7 @@ void QBluetoothSocketPrivate::channelClosed()
if (!isConnecting) {
q_ptr->setSocketState(QBluetoothSocket::UnconnectedState);
q_ptr->setOpenMode(QIODevice::NotOpen);
+ emit q_ptr->readChannelFinished();
emit q_ptr->disconnected();
} else {
state = QBluetoothSocket::UnconnectedState;
@@ -638,6 +639,7 @@ void QBluetoothSocket::abort()
d_ptr->abort();
setSocketState(QBluetoothSocket::UnconnectedState);
+ emit readChannelFinished();
emit disconnected();
}
@@ -726,6 +728,7 @@ void QBluetoothSocket::close()
d_ptr->close();
setSocketState(UnconnectedState);
+ emit readChannelFinished();
emit disconnected();
}