From f985e18f13984c4d77fa0cb7afaef9a6e3b2f313 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 23 Oct 2026 04:35:23 +0800 Subject: [PATCH] fix: clear m_BusIdList in DeviceManager::clear() to prevent ID accumulation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: DeviceManager::clear() resets all device state members but omits m_BusIdList, while addBusId() only appends without clearing, causing bus IDs to accumulate across refresh cycles 2. Fix: add m_BusIdList.clear() after m_DeviceClassMap.clear() in clear() so each refresh cycle starts with an empty bus ID list 3. Impact: device classification via getBusId()/indexOf() now uses only current-cycle bus IDs, eliminating stale-ID misclassification Influence: 1. Test device list correctness after multiple manual refreshes 2. Verify device classification remains consistent across refresh cycles 3. Confirm no duplicate or missing devices after repeated refreshes fix: 在 clear() 中复位 m_BusIdList 防止总线 ID 累积 1. 根因:DeviceManager::clear() 复位了所有设备状态成员但遗漏了 m_BusIdList,而 addBusId() 仅追加不清空,导致刷新周期中 总线 ID 持续累积 2. 方案:在 clear() 中 m_DeviceClassMap.clear() 之后添加 m_BusIdList.clear(),确保每个刷新周期开始时总线 ID 列表为空 3. 影响:getBusId()/indexOf() 设备分类仅使用当前周期的总线 ID, 消除旧 ID 残留导致的误分类 Influence: 1. 测试多次手动刷新后设备列表的正确性 2. 验证刷新周期之间设备分类的一致性 3. 确认反复刷新后设备无重复或缺失 PMS: BUG-DEF-002 --- deepin-devicemanager/src/DeviceManager/DeviceManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp b/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp index 2c040e852..ef2b92231 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp @@ -136,6 +136,7 @@ void DeviceManager::clear() m_ListDeviceMemory.clear(); m_ListDeviceCPU.clear(); m_DeviceClassMap.clear(); + m_BusIdList.clear(); qCDebug(appLog) << "All device resources cleared successfully"; }