From 5bd8a908ff32efab000b9cc8bffc7d82e04f9450 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Tue, 7 Jul 2026 14:37:53 +0800 Subject: [PATCH] fix(device): remove redundant loop in network device generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the outer loop iterating lstDevice in generatorNetworkDevice, as inner operations do not depend on the loop variable, fixing incorrect network device filtering. 移除generatorNetworkDevice中遍历lstDevice的多余外层循环,内层操作 不依赖循环变量,修复网络设备过滤异常的问题。 Log: 修复网络设备生成中循环冗余导致的过滤异常 PMS: BUG-369057 Influence: 修复后网络设备列表生成逻辑正确,避免无线网卡等设备被错误过滤。 --- .../src/GenerateDevice/DeviceGenerator.cpp | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp index 9b7f54a0..09fa3731 100644 --- a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp @@ -353,21 +353,20 @@ void DeviceGenerator::generatorNetworkDevice() continue; const QString &logicalNameLshw = (*it)["logical name"]; - for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { - const QString &macAddressLshw = (*it)["serial"]; - if (!isValidLogicalName(logicalNameLshw)) - continue; - if (!isValidMAC(macAddressLshw)) - continue; - if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive) && hasWlan) //common sense: one PC only have 1 wlan device - continue; + + const QString &macAddressLshw = (*it)["serial"]; + if (!isValidLogicalName(logicalNameLshw)) + continue; + if (!isValidMAC(macAddressLshw)) + continue; + if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive) && hasWlan) //common sense: one PC only have 1 wlan device + continue; - DeviceNetwork *device = new DeviceNetwork(); - device->setInfoFromLshw(*it); - lstDevice.append(device); - if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive)) - hasWlan = true; - } + DeviceNetwork *device = new DeviceNetwork(); + device->setInfoFromLshw(*it); + lstDevice.append(device); + if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive)) + hasWlan = true; } const QList> &lstHWInfo = DeviceManager::instance()->cmdInfo("hwinfo_network");