summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-04-30 15:57:13 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-05-04 12:15:48 +0000
commit8bf0702792f2d41764e62b63432870fee6a9e9c7 (patch)
treeaef724e53bdb72c99ecf2e5b2046d14addab7878
parentdb58c8691d9a0d6f9ee9226658b0fd6508a52c12 (diff)
Make Adapter1.RemoveDevice() call async
This function is called as part of QBluetoothLocalDevice::requestPairing(..., Unpaired). On heavy I/O systems this may be a rather slow function call. This patch ensures that the function is called asynchronously. Task-number: QTBUG-64735 Change-Id: I7e3b4ab3e9dca26a33af4d13bcc0ea64c44e1540 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp18
1 files changed, 11 insertions, 7 deletions
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: