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 --- examples/bluetooth/heartrate-game/devicehandler.cpp | 6 +++--- src/bluetooth/android/lowenergynotificationhub.cpp | 2 +- src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp index ab203c3f..3d263a4c 100644 --- a/examples/bluetooth/heartrate-game/devicehandler.cpp +++ b/examples/bluetooth/heartrate-game/devicehandler.cpp @@ -259,11 +259,11 @@ void DeviceHandler::updateDemoHR() { int randomValue = 0; if (m_currentValue < 30) { // Initial value - randomValue = 55 + QRandomGenerator::bounded(30); + randomValue = 55 + QRandomGenerator::global()->bounded(30); } else if (!m_measuring) { // Value when relax - randomValue = qBound(55, m_currentValue - 2 + QRandomGenerator::bounded(5), 75); + randomValue = qBound(55, m_currentValue - 2 + QRandomGenerator::global()->bounded(5), 75); } else { // Measuring - randomValue = m_currentValue + QRandomGenerator::bounded(10) - 2; + randomValue = m_currentValue + QRandomGenerator::global()->bounded(10) - 2; } addMeasurement(randomValue); diff --git a/src/bluetooth/android/lowenergynotificationhub.cpp b/src/bluetooth/android/lowenergynotificationhub.cpp index 9f90e3de..fee8ce19 100644 --- a/src/bluetooth/android/lowenergynotificationhub.cpp +++ b/src/bluetooth/android/lowenergynotificationhub.cpp @@ -84,7 +84,7 @@ LowEnergyNotificationHub::LowEnergyNotificationHub(const QBluetoothAddress &remo lock.lockForWrite(); while (true) { - javaToCtoken = QRandomGenerator::get32(); + javaToCtoken = QRandomGenerator::global()->generate(); if (!hubMap()->contains(javaToCtoken)) break; } 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