From 035ba1c10e33a21b9fd8f4dd8423e36d9b91016c Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 22 Dec 2021 14:59:02 +0100 Subject: [PATCH] Use ranged for loop in DeviceManager Change-Id: Ic3017de13be1cdff63d800bfe94af46055d93b54 Reviewed-by: hjk --- .../devicesupport/devicemanager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index 60172aa85d4..af095ce7095 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -103,7 +103,7 @@ void DeviceManager::replaceInstance() const QList newIds = Utils::transform(DeviceManagerPrivate::clonedInstance->d->devices, &IDevice::id); - for (IDevice::Ptr dev : m_instance->d->devices) { + for (const IDevice::ConstPtr &dev : qAsConst(m_instance->d->devices)) { if (!newIds.contains(dev->id())) dev->aboutToBeRemoved(); } @@ -132,7 +132,7 @@ DeviceManager *DeviceManager::cloneInstance() void DeviceManager::copy(const DeviceManager *source, DeviceManager *target, bool deep) { if (deep) { - foreach (const IDevice::ConstPtr &device, source->d->devices) + for (const IDevice::ConstPtr &device : qAsConst(source->d->devices)) target->d->devices << device->clone(); } else { target->d->devices = source->d->devices; @@ -178,8 +178,8 @@ void DeviceManager::load() userDevices = fromMap(reader.restoreValues().value(DeviceManagerKey).toMap(), &defaultDevices); // Insert devices into the model. Prefer the higher device version when there are multiple // devices with the same id. - foreach (IDevice::Ptr device, userDevices) { - foreach (const IDevice::Ptr &sdkDevice, sdkDevices) { + for (IDevice::ConstPtr device : qAsConst(userDevices)) { + for (const IDevice::Ptr &sdkDevice : qAsConst(sdkDevices)) { if (device->id() == sdkDevice->id()) { if (device->version() < sdkDevice->version()) device = sdkDevice; @@ -190,7 +190,7 @@ void DeviceManager::load() addDevice(device); } // Append the new SDK devices to the model. - foreach (const IDevice::Ptr &sdkDevice, sdkDevices) + for (const IDevice::Ptr &sdkDevice : qAsConst(sdkDevices)) addDevice(sdkDevice); // Overwrite with the saved default devices. @@ -229,7 +229,7 @@ QList DeviceManager::fromMap(const QVariantMap &map, defaultDevices->insert(Utils::Id::fromString(it.key()), Utils::Id::fromSetting(it.value())); } const QVariantList deviceList = map.value(QLatin1String(DeviceListKey)).toList(); - foreach (const QVariant &v, deviceList) { + for (const QVariant &v : deviceList) { const QVariantMap map = v.toMap(); const IDeviceFactory * const factory = restoreFactory(map); if (!factory) @@ -253,7 +253,7 @@ QVariantMap DeviceManager::toMap() const } map.insert(QLatin1String(DefaultDevicesKey), defaultDeviceMap); QVariantList deviceList; - foreach (const IDevice::ConstPtr &device, d->devices) + for (const IDevice::ConstPtr &device : qAsConst(d->devices)) deviceList << device->toMap(); map.insert(QLatin1String(DeviceListKey), deviceList); return map; @@ -264,7 +264,7 @@ void DeviceManager::addDevice(const IDevice::ConstPtr &_device) const IDevice::Ptr device = _device->clone(); QStringList names; - foreach (const IDevice::ConstPtr &tmp, d->devices) { + for (const IDevice::ConstPtr &tmp : qAsConst(d->devices)) { if (tmp->id() != device->id()) names << tmp->displayName(); }