From 675bff46dad3d307d7b01e6c13b5e6e945e49225 Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Mon, 30 May 2022 12:09:11 +0200 Subject: [PATCH] iostool: Remove foreach / Q_FOREACH usage Task-number: QTCREATORBUG-27464 Change-Id: I26decce7cc8748c9707fb5aae9566bab89e73e25 Reviewed-by: Eike Ziller --- src/tools/iostool/iosdevicemanager.cpp | 8 +++++--- src/tools/iostool/mobiledevicelib.cpp | 3 ++- src/tools/iostool/relayserver.cpp | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tools/iostool/iosdevicemanager.cpp b/src/tools/iostool/iosdevicemanager.cpp index 0f24d58868f..2e6aa4ccf36 100644 --- a/src/tools/iostool/iosdevicemanager.cpp +++ b/src/tools/iostool/iosdevicemanager.cpp @@ -560,7 +560,7 @@ void IosDeviceManagerPrivate::addDevice(AMDeviceRef device) m_pendingLookups.remove(devId); devices << m_pendingLookups.values(QString()); m_pendingLookups.remove(QString()); - foreach (PendingDeviceLookup *devLookup, devices) { + for (PendingDeviceLookup *devLookup : qAsConst(devices)) { if (debugAll) qDebug() << "found pending op"; devLookup->timer.stop(); devLookup->callback(devId, device, devLookup->userData); @@ -589,8 +589,10 @@ void IosDeviceManagerPrivate::removeDevice(AMDeviceRef device) void IosDeviceManagerPrivate::checkPendingLookups() { - foreach (const QString &deviceId, m_pendingLookups.keys()) { - foreach (PendingDeviceLookup *deviceLookup, m_pendingLookups.values(deviceId)) { + const QStringList keys = m_pendingLookups.keys(); + for (const QString &deviceId : keys) { + const QList values = m_pendingLookups.values(deviceId); + for (PendingDeviceLookup *deviceLookup : values) { if (!deviceLookup->timer.isActive()) { m_pendingLookups.remove(deviceId, deviceLookup); deviceLookup->callback(deviceId, 0, deviceLookup->userData); diff --git a/src/tools/iostool/mobiledevicelib.cpp b/src/tools/iostool/mobiledevicelib.cpp index 79c4054a0d4..025248262f1 100644 --- a/src/tools/iostool/mobiledevicelib.cpp +++ b/src/tools/iostool/mobiledevicelib.cpp @@ -44,7 +44,8 @@ MobileDeviceLib::MobileDeviceLib() if (!load()) addError(QLatin1String("Error loading MobileDevice.framework")); if (!errors().isEmpty()) { - foreach (const QString &msg, errors()) + const QStringList errs = errors(); + for (const QString &msg : errs) addError(msg); } setLogLevel(5); diff --git a/src/tools/iostool/relayserver.cpp b/src/tools/iostool/relayserver.cpp index 03181a10ac4..312b3bd66d4 100644 --- a/src/tools/iostool/relayserver.cpp +++ b/src/tools/iostool/relayserver.cpp @@ -284,8 +284,7 @@ bool RelayServer::startServer() void RelayServer::stopServer() { - foreach (Relayer *connection, m_connections) - delete connection; + qDeleteAll(m_connections); if (m_ipv4Server.isListening()) m_ipv4Server.close(); if (m_ipv6Server.isListening())