fix: suppress three not-find warnings in net-view control center - #613
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEliminates three warning-producing updates to absent network items by removing dead disabled-item calls and aligning airplane-mode tips updates with the Net_AirplaneTips creation guard, without changing effective UI behavior or airplane-mode state handling. Sequence diagram for guarded airplane-mode tips updatesequenceDiagram
participant NetManagerPrivate
participant Flags
participant ControlCenterItems
NetManagerPrivate->>Flags: testFlags(NetType::Net_AirplaneTips)
alt Net_AirplaneTips enabled
NetManagerPrivate->>ControlCenterItems: updateItemVisible("NetAirplaneModeTipsItem", enabled && m_supportWireless)
else Net_AirplaneTips disabled
NetManagerPrivate-->>ControlCenterItems: no update
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
CLA Assistant Lite bot: You can retrigger this bot by commenting recheck in this Pull Request |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码语法正确,逻辑清晰。updateControlEnabled() 中移除的死代码(devDisabled 计算和 updateItemVisible 调用)不影响现有功能,因为 NetWiredDisabledItem/NetWirelessDisabledItem 从未被实例化。updateAirplaneMode() 中新增的 flags().testFlags(NetType::Net_AirplaneTips) 守卫与 init() 函数第 278 行的创建守卫完全对称,逻辑一致。m_airplaneMode 追踪和 airplaneModeChanged 信号保持不变。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议在 flags().testFlags(NetType::Net_AirplaneTips) 守卫条件处添加简要注释,说明 NetAirplaneModeTipsItem 仅在 Net_AirplaneTips 标志存在时创建,因此更新可见性时也需要对应守卫。其余代码结构清晰,改动最小化,死代码移除得当。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 移除死代码减少了不必要的 updateItemVisible() 函数调用和条件判断,对性能有轻微正面影响。flags().testFlags() 是轻量级位运算,无性能开销。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 本次变更不涉及用户输入处理、网络通信、文件操作或权限管理,无安全风险。代码仅修改 UI 项的可见性更新逻辑,不引入任何安全漏洞。 💡 改进建议代码示例// 建议在守卫条件处添加注释
void NetManagerPrivate::updateAirplaneMode(bool enabled)
{
if (m_airplaneMode != enabled) {
m_airplaneMode = enabled;
Q_Q(NetManager);
Q_EMIT q->airplaneModeChanged(m_airplaneMode);
}
// NetAirplaneModeTipsItem 仅在 Net_AirplaneTips 标志存在时创建(见 init()),
// 更新可见性时需要对应的守卫以避免对不存在的项发出警告
if (flags().testFlags(NetType::Net_AirplaneTips)) {
updateItemVisible("NetAirplaneModeTipsItem", enabled && m_supportWireless);
}
}本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 52cyb, caixr23 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
DDE-151: control center network module logs three runtime warnings for NetWiredDisabledItem / NetWirelessDisabledItem / NetAirplaneModeTipsItem. 1. NetWiredDisabledItem / NetWirelessDisabledItem are never instantiated (factory returns nullptr; no NetItemNew+addItem). Remove the dead updateItemVisible calls in updateControlEnabled() and updateAirplaneMode(). Preserve pEnabled/pEnabledable logic and parentItem->updateenabled()/ updateenabledable(). 2. NetAirplaneModeTipsItem is created in init() under Net_AirplaneTips guard, but updateAirplaneMode() called updateItemVisible on it unconditionally. Net_DccFlags lacks Net_AirplaneTips, so the item is not created in control center and the call warns. Add symmetric flags().testFlags(Net_AirplaneTips) guard. dock/lock/greeter unchanged. m_airplaneMode tracking and airplaneModeChanged signal unchanged. PMS: https://pms.uniontech.com/task-view-392413.html Issue: DDE-151
Remove the never-instantiated NetWiredDisabledItem and NetWirelessDisabledItem item types and all associated dead code: - enum values WirelessDisabledItem/WiredDisabledItem (nettype.h) - class declarations NetWiredDisabledItem/NetWirelessDisabledItem (netitem.h) - factory empty break cases (netitemprivate.cpp) - delegate branches in getItemSpacing/paint/createEditor (netdelegate.cpp) - NetDisabledWidget class declaration and implementation (netdelegate.h/cpp) - unused #include <QToolButton> (netdelegate.cpp) These types were never created by the factory (empty break), so all delegate branches handling them were unreachable dead code. This completes the cleanup started in the previous commit, making the removal of the 'not find' warning calls consistent with the removal of all rendering/display scaffolding for the abandoned placeholder feature. PMS: https://pms.uniontech.com/task-view-392413.html Issue: DDE-151
f481319 to
b41d5bd
Compare
|
/forcemerge |
|
This pr force merged! (status: unstable) |
关联信息
问题
控制中心-网络模块运行时打印三条 "not find" 警告:
根因
NetWiredDisabledItem/NetWirelessDisabledItem:这两个 item 从未被实例化(工厂NetItemPrivate::New()对这两个类型是空break,全仓库无任何NetItemNew+addItem创建它们)。updateControlEnabled()和updateAirplaneMode()仍以固定字符串 id 调用updateItemVisible(...),findItem()恒返回nullptr,命中告警分支。属 2024-10 首次引入即存在的历史遗留死代码。NetAirplaneModeTipsItem:该 item 在init()中被Net_AirplaneTipsflag 守卫创建,但updateAirplaneMode()中的updateItemVisible调用是无条件的。控制中心使用Net_DccFlags(不含Net_AirplaneTips),item 未创建时调用落空打告警。dock/锁屏/greeter(flag 含Net_AirplaneTips)不受影响。修复
移除
updateControlEnabled()中devDisabled局部变量及其计算、updateItemVisible(... "NetWiredDisabledItem"/"NetWirelessDisabledItem" ...)死调用。保留pEnabled/pEnabledable计算与parentItem->updateenabled()/updateenabledable()现有生效逻辑。移除
updateAirplaneMode()中if (enabled)块内对NetWirelessDisabledItem、NetWiredDisabledItem的两条死调用及空块。给
updateAirplaneMode()中updateItemVisible("NetAirplaneModeTipsItem", ...)调用补上flags().testFlags(NetType::Net_AirplaneTips)守卫,与init()中的创建守卫对称。影响
Net_DccFlags不含Net_AirplaneTips):不再触发三条 "not find" 警告,行为不变(原调用本就是"找不到 item 直接 return"的空操作)。Net_AirplaneTips):行为完全不变。m_airplaneMode状态跟踪与airplaneModeChanged信号发射不受影响。Summary by Sourcery
Remove obsolete network disabled-item handling and align airplane-mode tip updates with item creation flags.
Bug Fixes:
Enhancements: