From 5de3e0df0f55e63c95cc974c9c4623f0aae1cf11 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 23 Oct 2026 08:27:41 +0800 Subject: [PATCH] fix: clear boardVendorKey cache in else branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: static variable boardVendorKey was not cleared in the else branch of checkBoardVendorFlag() when dmidecode output did not match any known model string, causing stale cache values to persist across calls 2. Fix: add boardVendorKey.clear() at the entry of the else branch to reset the static variable before dmidecode matching logic runs 3. Impact: stale non-empty values no longer mask the M900/W525 fallback check at line 206; only the else branch is affected, the switch branch and other functions remain unchanged Influence: 1. Test checkBoardVendorFlag on unknown device models to verify boardVendorKey is empty after call 2. Test M900/W525 fallback logic triggers correctly after unknown model 3. Verify known model detection (KLVV/KLVU/PGUV/PGUW/PGUX) still works fix: 修复else分支中boardVendorKey缓存残留问题 1. 根因:checkBoardVendorFlag()的else分支中,当dmidecode输出不匹配 任何已知机型字符串时,未清空静态变量boardVendorKey,导致旧值跨 调用残留 2. 方案:在else分支入口处添加boardVendorKey.clear(),在进入dmidecode 匹配逻辑前重置静态变量 3. 影响:残留的非空值不再屏蔽第206行M900/W525兜底检查,仅影响else 分支行为,switch分支和其他函数不受影响 Influence: 1. 测试未知机型设备上调用checkBoardVendorFlag后boardVendorKey为空 2. 测试M900/W525兜底逻辑在未知机型后能正确触发 3. 验证已知机型检测(KLVV/KLVU/PGUV/PGUW/PGUX)功能正常 --- deepin-devicemanager/src/commonfunction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/deepin-devicemanager/src/commonfunction.cpp b/deepin-devicemanager/src/commonfunction.cpp index 9f8005469..b5db93f38 100644 --- a/deepin-devicemanager/src/commonfunction.cpp +++ b/deepin-devicemanager/src/commonfunction.cpp @@ -181,6 +181,7 @@ QString Common::checkBoardVendorFlag() break; } }else{ + boardVendorKey.clear(); QProcess process; process.start("dmidecode", QStringList() << "-s" << "system-product-name"); process.waitForFinished(-1);