diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-14 11:08:18 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-15 07:56:46 +0000 |
commit | a0ade068004ad869d6235ae8d6cd5e2050bf765d (patch) | |
tree | 42c949ba2fa7fcd4ab5356293d1ef3cad1c436f6 /src/bluetooth/qbluetoothlocaldevice_bluez.cpp | |
parent | 84f0e76c647e7f09529b79525b2d4fbc698576d8 (diff) |
Replace foreach with for loop and set QT_NO_FOREACH
To avoid unnecessary copies, const is used wherever possible.
Change-Id: Ic743716512751cfd24fad5bd37c244b115dd26fe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothlocaldevice_bluez.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp index c247f679..8612fd5c 100644 --- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp @@ -249,7 +249,8 @@ QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices() if (reply.isError()) return localDevices; - foreach (const QDBusObjectPath &path, reply.value()) { + const QList<QDBusObjectPath> paths = reply.value(); + for (const QDBusObjectPath &path : paths) { QBluetoothHostInfo hostinfo; OrgBluezAdapterInterface adapter(QStringLiteral("org.bluez"), path.path(), QDBusConnection::systemBus()); @@ -770,7 +771,8 @@ void QBluetoothLocalDevicePrivate::initializeAdapter() if (reply.isError()) return; - foreach (const QDBusObjectPath &path, reply.value()) { + const QList<QDBusObjectPath> paths = reply.value(); + for (const QDBusObjectPath &path : paths) { OrgBluezAdapterInterface *tmpAdapter = new OrgBluezAdapterInterface(QStringLiteral("org.bluez"), path.path(), QDBusConnection::systemBus()); @@ -1067,7 +1069,7 @@ void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &devic void QBluetoothLocalDevicePrivate::_q_deviceRemoved(const QDBusObjectPath &device) { - foreach (OrgBluezDeviceInterface *deviceInterface, devices) { + for (OrgBluezDeviceInterface *deviceInterface : qAsConst(devices)) { if (deviceInterface->path() == device.path()) { devices.remove(deviceInterface); delete deviceInterface; // deviceDisconnected is already emitted by _q_devicePropertyChanged @@ -1113,7 +1115,8 @@ void QBluetoothLocalDevicePrivate::createCache() qCWarning(QT_BT_BLUEZ) << reply.error().message(); return; } - foreach (const QDBusObjectPath &device, reply.value()) { + const QList<QDBusObjectPath> knownDevices = reply.value(); + for (const QDBusObjectPath &device : knownDevices) { OrgBluezDeviceInterface *deviceInterface = new OrgBluezDeviceInterface(QStringLiteral("org.bluez"), device.path(), |