From 6efa28f0c193adf0151bb78d9660fa1fe6e8c525 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 24 Oct 2017 20:39:21 -0700 Subject: Update to new QRandomGenerator API Change-Id: I69f37f9304f24709a823fffd14e676c097712329 Reviewed-by: Timur Pocheptsov Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/bluetooth/qbluetoothlocaldevice_bluez.cpp') diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp index 0982573e..4eb3ca58 100644 --- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp @@ -800,7 +800,7 @@ void QBluetoothLocalDevicePrivate::initializeAdapter() SLOT(PropertyChanged(QString, QDBusVariant))); agent_path = agentPath; - agent_path.append(QString::fromLatin1("/%1").arg(QRandomGenerator::get32())); + agent_path.append(QString::fromLatin1("/%1").arg(QRandomGenerator::global()->generate())); } } @@ -1164,7 +1164,7 @@ QString QBluetoothLocalDevicePrivate::RequestPinCode(const QDBusObjectPath &in0) Q_Q(QBluetoothLocalDevice); qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << in0.path(); // seeded in constructor, 6 digit pin - QString pin = QString::fromLatin1("%1").arg(QRandomGenerator::bounded(1000000)); + QString pin = QString::fromLatin1("%1").arg(QRandomGenerator::global()->bounded(1000000)); pin = QString::fromLatin1("%1").arg(pin, 6, QLatin1Char('0')); emit q->pairingDisplayPinCode(address, pin); @@ -1276,7 +1276,7 @@ uint QBluetoothLocalDevicePrivate::RequestPasskey(const QDBusObjectPath &in0) { Q_UNUSED(in0); qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO; - return (QRandomGenerator::bounded(1000000)); + return (QRandomGenerator::global()->bounded(1000000)); } // Bluez 4 -- cgit v1.2.3 From 8bf0702792f2d41764e62b63432870fee6a9e9c7 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 30 Apr 2018 15:57:13 +0200 Subject: 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 Reviewed-by: Denis Shienkov Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/bluetooth/qbluetoothlocaldevice_bluez.cpp') 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: -- cgit v1.2.3