Skip to content

fix: suppress three not-find warnings in net-view control center - #613

Merged
deepin-bot[bot] merged 2 commits into
masterfrom
fix/dde-151-netitem-not-find-warnings
Sep 3, 2026
Merged

fix: suppress three not-find warnings in net-view control center#613
deepin-bot[bot] merged 2 commits into
masterfrom
fix/dde-151-netitem-not-find-warnings

Conversation

@52cyb

@52cyb 52cyb commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

关联信息

问题

控制中心-网络模块运行时打印三条 "not find" 警告:

Update item visible false, The item: "NetWiredDisabledItem" not find!
Update item visible false, The item: "NetWirelessDisabledItem" not find!
Update item visible false, The item: "NetAirplaneModeTipsItem" not find!

根因

  1. NetWiredDisabledItem / NetWirelessDisabledItem:这两个 item 从未被实例化(工厂 NetItemPrivate::New() 对这两个类型是空 break,全仓库无任何 NetItemNew + addItem 创建它们)。updateControlEnabled()updateAirplaneMode() 仍以固定字符串 id 调用 updateItemVisible(...)findItem() 恒返回 nullptr,命中告警分支。属 2024-10 首次引入即存在的历史遗留死代码。

  2. NetAirplaneModeTipsItem:该 item 在 init() 中被 Net_AirplaneTips flag 守卫创建,但 updateAirplaneMode() 中的 updateItemVisible 调用是无条件的。控制中心使用 Net_DccFlags(不含 Net_AirplaneTips),item 未创建时调用落空打告警。dock/锁屏/greeter(flag 含 Net_AirplaneTips)不受影响。

修复

  1. 移除 updateControlEnabled()devDisabled 局部变量及其计算、updateItemVisible(... "NetWiredDisabledItem"/"NetWirelessDisabledItem" ...) 死调用。保留 pEnabled/pEnabledable 计算与 parentItem->updateenabled()/updateenabledable() 现有生效逻辑。

  2. 移除 updateAirplaneMode()if (enabled) 块内对 NetWirelessDisabledItemNetWiredDisabledItem 的两条死调用及空块。

  3. updateAirplaneMode()updateItemVisible("NetAirplaneModeTipsItem", ...) 调用补上 flags().testFlags(NetType::Net_AirplaneTips) 守卫,与 init() 中的创建守卫对称。

影响

  • 控制中心(Net_DccFlags 不含 Net_AirplaneTips):不再触发三条 "not find" 警告,行为不变(原调用本就是"找不到 item 直接 return"的空操作)。
  • dock / 锁屏 / greeter(flag 含 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:

  • Suppress spurious missing-item warnings in the network control center by removing obsolete disabled-item updates and guarding airplane-mode tips updates by their feature flag.

Enhancements:

  • Remove unused wired and wireless disabled item types and their associated delegate, widget, and factory code.

@sourcery-ai

sourcery-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Eliminates 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 update

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Remove updates targeting two never-instantiated disabled-device items.
  • Delete the unused disabled-state calculation.
  • Remove unconditional visibility updates for wired and wireless disabled items while preserving parent enabled-state updates and airplane-mode state handling.
net-view/operation/netmanager.cpp
Guard airplane-mode tips visibility updates with the same feature flag used during item creation.
  • Only update NetAirplaneModeTipsItem when Net_AirplaneTips is enabled.
  • Keep airplane-mode signal emission and state tracking unchanged.
net-view/operation/netmanager.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 99 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 99 分,大于 70 分通过阈值,代码质量优秀。本次变更修复了控制中心网络模块的三个运行时警告,移除了引用不存在 UI 项的死代码,并添加了与 init() 函数对称的 flags 守卫条件,逻辑正确且改动最小化。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码语法正确,逻辑清晰。updateControlEnabled() 中移除的死代码(devDisabled 计算和 updateItemVisible 调用)不影响现有功能,因为 NetWiredDisabledItem/NetWirelessDisabledItem 从未被实例化。updateAirplaneMode() 中新增的 flags().testFlags(NetType::Net_AirplaneTips) 守卫与 init() 函数第 278 行的创建守卫完全对称,逻辑一致。m_airplaneMode 追踪和 airplaneModeChanged 信号保持不变。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. net-view/operation/netmanager.cpp:1041 - updateAirplaneMode() 中新增的 flags().testFlags(Net_AirplaneTips) 守卫条件缺少内联注释

建议: 建议在 flags().testFlags(NetType::Net_AirplaneTips) 守卫条件处添加简要注释,说明 NetAirplaneModeTipsItem 仅在 Net_AirplaneTips 标志存在时创建,因此更新可见性时也需要对应守卫。其余代码结构清晰,改动最小化,死代码移除得当。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 移除死代码减少了不必要的 updateItemVisible() 函数调用和条件判断,对性能有轻微正面影响。flags().testFlags() 是轻量级位运算,无性能开销。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 本次变更不涉及用户输入处理、网络通信、文件操作或权限管理,无安全风险。代码仅修改 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 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Multica Agent added 2 commits September 3, 2026 17:31
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
@52cyb
52cyb force-pushed the fix/dde-151-netitem-not-find-warnings branch from f481319 to b41d5bd Compare September 3, 2026 09:31
@52cyb

52cyb commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit f19a8b0 into master Sep 3, 2026
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants