Repository navigation
Conversation
1. Uncomment m_primaryConnectionType member variable in NetManagerPrivate 2. Initialize m_primaryConnectionType to Wired in constructor 3. Return actual value from primaryConnectionType() instead of hardcoded Unknown 4. Implement updatePrimaryConnectionType() to store value and emit change signal Log: Fix network icon showing wireless instead of wired when both are connected fix(network): 实现 NetManager 主连接类型追踪功能 1. 取消注释 NetManagerPrivate 中的 m_primaryConnectionType 成员变量 2. 构造函数中初始化 m_primaryConnectionType 为 Wired 3. primaryConnectionType() 返回实际值而非硬编码 Unknown 4. 实现 updatePrimaryConnectionType() 存储值并发送变更信号 Log: 修复有线和无线同时连接时任务栏网络图标显示为无线图标的问题 PMS: BUG-375223
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR completes the existing primary connection type data path by restoring private-state storage, Wired initialization, getter access, and change-signal emission. Consumers such as network icon, IP display, and tips can now react to the actual primary connection, especially when wired and wireless links are simultaneously active. Sequence diagram for primary connection type updatessequenceDiagram
participant NetworkManagerQt
participant NetManagerThreadPrivate
participant NetManagerPrivate
participant NetManager
participant NetStatus
NetworkManagerQt->>NetManagerThreadPrivate: primary connection type data changes
NetManagerThreadPrivate->>NetManagerPrivate: onDataChanged
NetManagerPrivate->>NetManagerPrivate: updatePrimaryConnectionType(type)
NetManagerPrivate->>NetManager: primaryConnectionTypeChanged(type)
NetManager->>NetStatus: updateNetworkIcon()
NetManager->>NetStatus: updateNetworkTips()
NetStatus->>NetManager: primaryConnectionType()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。所有取消注释的代码均为有效的 C++ 代码,遵循 Qt d-pointer 模式。primaryConnectionType() getter 正确返回 d->m_primaryConnectionType;构造函数正确初始化 m_primaryConnectionType(Wired) 作为默认值;updatePrimaryConnectionType() 正确使用 Q_Q 宏获取公共类指针并发送 primaryConnectionTypeChanged 信号。数据管道完整:NetworkManager → NetManagerThreadPrivate → onDataChanged → updatePrimaryConnectionType → primaryConnectionTypeChanged 信号 → NetStatus。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构清晰,注释完整。改动仅 4 处跨 2 个文件,全部在 NetManager/NetManagerPrivate 类内,不改签名/接口。代码模式与同类函数 updateAirplaneMode(netmanager.cpp:1035-1044)完全一致,保持了一致性。无重复代码,无残留调试代码。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。updatePrimaryConnectionType() 使用条件判断(m_primaryConnectionType != type)避免不必要的信号发射,仅在实际变化时才触发 UI 更新。ConnectionType 为枚举类型,按值传递高效。整体复杂度 O(1),无性能瓶颈。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 安全合规。本次改动不涉及用户输入处理、外部数据交互、文件操作或网络通信。type 参数来源于 NetworkManager 内部数据管道(onDataChanged → value.toInt()),不涉及外部不可信数据。无命令注入、SQL 注入、路径遍历等安全风险。无硬编码密钥或敏感信息。 💡 改进建议代码示例// 本次改动无需修复代码示例,所有变更均为取消注释已有代码
// netmanager_p.h - 取消注释成员变量
NetManager::ConnectionType m_primaryConnectionType;
// netmanager.cpp - getter 返回实际值
NetManager::ConnectionType NetManager::primaryConnectionType() const
{
return d->m_primaryConnectionType;
}
// netmanager.cpp - 构造函数初始化
, m_primaryConnectionType(NetManager::ConnectionType::Wired)
// netmanager.cpp - 更新函数体
void NetManagerPrivate::updatePrimaryConnectionType(NetManager::ConnectionType type)
{
if (m_primaryConnectionType != type) {
m_primaryConnectionType = type;
Q_Q(NetManager);
Q_EMIT q->primaryConnectionTypeChanged(m_primaryConnectionType);
}
}本报告由 AI 代码审查工具自动生成 |
|
#626 在这里跟踪修复,此PR关闭 |
Root Cause Analysis
The
NetManagerclass indde-network-corenever implemented primary connection type tracking. TheprimaryConnectionType()getter was a stub returningUnknown, theupdatePrimaryConnectionType()function body was fully commented out, and them_primaryConnectionTypemember variable was also commented out. When both wired and wireless connections are active,updateNetworkIcon()callsprimaryConnectionType(), getsUnknown, and falls back to selecting the wireless icon by default.Key evidence:
netmanager.cpp:84-86(stub getter),netmanager.cpp:1046-1053(commented-out function body),netstatus.cpp:798-803(icon fallback logic).Fix
Uncomment and enable the existing primary connection type tracking infrastructure — 4 changes across 2 files, all within
NetManager/NetManagerPrivateclasses, no signature or interface changes:m_primaryConnectionTypemember variable innetmanager_p.hm_primaryConnectionType(Wired)innetmanager.cppprimaryConnectionType()to returnd->m_primaryConnectionTypeinstead of hardcodedUnknownupdatePrimaryConnectionType()function body to store the value and emitprimaryConnectionTypeChangedsignalThe data pipeline from NetworkManagerQt →
NetManagerThreadPrivate→NetManagerPrivate::onDataChanged→updatePrimaryConnectionTypewas already wired; only the storage and signal emission were missing.Change Safety Assessment
Code Safety
primaryConnectionType()innetstatus.cpp(lines 550, 553, 621, 629, 798, 987, 1051) currently receiveUnknownand will now receive the actual connection type. TheprimaryConnectionTypeChangedsignal is already connected toupdateNetworkIconandupdateNetworkTipsinnetstatus.cpp:73-74.Business Impact Scope
Verification Suggestion
Test with both wired and wireless simultaneously connected — verify the taskbar network icon shows wired. Then test wired-only and wireless-only scenarios to confirm no regression.
根因分析
dde-network-core中NetManager类的主连接类型追踪功能从未实现。primaryConnectionType()getter 为桩函数返回Unknown,updatePrimaryConnectionType()函数体被完全注释掉,m_primaryConnectionType成员变量也被注释。当有线和无线同时连接时,updateNetworkIcon()调用primaryConnectionType()得到Unknown,fallback 默认选择无线图标。关键证据:
netmanager.cpp:84-86(桩 getter)、netmanager.cpp:1046-1053(注释掉的函数体)、netstatus.cpp:798-803(图标 fallback 逻辑)。修复方案
取消注释并启用已有的主连接类型追踪基础设施——4 处改动跨 2 个文件,均在
NetManager/NetManagerPrivate类内,不改签名/接口:netmanager_p.h中的m_primaryConnectionType成员变量netmanager.cpp构造函数中的m_primaryConnectionType(Wired)初始化primaryConnectionType()返回d->m_primaryConnectionType而非硬编码UnknownupdatePrimaryConnectionType()函数体,存储值并发送primaryConnectionTypeChanged信号从 NetworkManagerQt →
NetManagerThreadPrivate→NetManagerPrivate::onDataChanged→updatePrimaryConnectionType的数据管道已接通,仅缺少存储和信号发送。改动安全评估
代码安全评估
netstatus.cpp中primaryConnectionType()的全部 6 个调用点(行 550、553、621、629、798、987、1051)当前收到Unknown,修复后将收到实际连接类型。primaryConnectionTypeChanged信号已在netstatus.cpp:73-74连接到updateNetworkIcon和updateNetworkTips。业务影响范围
验证建议
测试有线+无线同时连接场景——验证任务栏网络图标显示有线图标。然后测试仅有线和仅无线场景,确认无回归。
PMS: BUG-375223
Summary by Sourcery
Bug Fixes: