Skip to content

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Dec 1, 2025

pick develop/eagle to master

Summary by Sourcery

Update device manager GPU, network, monitor handling and modernize several interfaces and threading helpers for better safety and compatibility.

Bug Fixes:

  • Adjust GPU memory detection to read from the new /sys/kernel/debug/gc/total_mem format and normalize sizes in GB.
  • Fix wake-on-LAN ioctl interface name handling to respect IFNAMSIZ limits and ensure structures are properly initialized.
  • Treat additional Wi‑Fi descriptors as network devices when parsing hwinfo output.
  • Ensure monitor subtitles are cleared on special-comType hardware so stale names are not shown.

Enhancements:

  • Hide or skip table views for the Monitor category in multi-info pages on special-comType devices and add the corresponding translation.
  • Pass QString and QStringList parameters by const reference in DBus driver interfaces and other APIs to avoid unnecessary copies.
  • Mark thread-related destructors and QRunnable-based task classes with override for correctness.
  • Pass driver lists to DriverScanner by const reference to avoid copying.
  • Improve OEM TOML parsing and command task constructors to use const QString references for their inputs.

GongHeng2017 and others added 9 commits December 1, 2025 14:31
-- Code Logic error, "sizeof(logicalName::toStdString().c_str())" always return 8,
   not the length of logicalName.
-- So, When the length more than 8, the net card will can not find.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-326565.html
-- Function parameter should be passed by const reference.
-- A destructor but is not marked 'override'.
-- When dealing with inheritance, deleting a derived class object through a base class
pointer without a virtual destructor will lead to problems.
Implemented information masking for certain display configurations on
special hardware models.

pick from: linuxdeepin@71f38f8

Log: Add display info filtering for special devices
Bug: https://pms.uniontech.com/bug-view-328971.html
Change-Id: Ie2826605b25bdb1ef1c4956bd6856af95284b108
update monitor of subtitle for specific device models

pick from: linuxdeepin@26ac1a4

Log: update monitor of subtitle for specific device models
Bug: https://pms.uniontech.com/bug-view-328971.html
Change-Id: Ica04bfa281acf49fde7fcdbbd8b84bf0d357afbe
update filter for some unkown netcard

pick from: linuxdeepin@3165c94

Log: update filter for some unkown netcard
Bug: https://pms.uniontech.com/bug-view-328939.html
Change-Id: I31e2da109343b3646f497389fa8735c9b6bb3c7b
Enhanced model identification for external adapter-based NICs (including
Type-C to RJ45 converters) to ensure reliable device model retrieval.

Log: Fix NIC model detection failure
Bug: https://pms.uniontech.com/bug-view-329931.html
Change-Id: I25a5b0485228f8c431866608754601519c22b612
-- The scope of the variable can be reduced.
-- Uninitialized struct member: resoulution
-- Local varible pathList shadows outer variable
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 1, 2025

Reviewer's Guide

Refines GPU memory parsing to read a new kernel debug path and handle generic size units, fixes Wake-on-LAN ioctl interface name handling, adjusts monitor page/table behavior for special devices, improves type safety and const-correctness across several classes, enhances network device naming and Wi‑Fi detection, and adds minor UI translation updates.

Updated class diagram for driver control, device info, and UI types

classDiagram
    class DBusDriverInterface {
        +slotProcessChange(value: qint32, detail: const QString &): void
        +slotProcessEnd(success: bool, msg: const QString &): void
        +slotDownloadProgressChanged(msg: const QStringList &): void
    }

    class CmdTool {
        +parseOemTomlInfo(filename: const QString &): bool
    }

    class GetInfoPool

    class CmdTask {
        +CmdTask(key: const QString &, file: const QString &, info: const QString &, parent: GetInfoPool *)
        +run(): void
        +~CmdTask()
        -m_Key: QString
        -m_File: QString
        -m_Info: QString
        -m_Parent: GetInfoPool *
    }

    CmdTask ..> GetInfoPool : parent

    class DriverScanner {
        +setDriverList(lstInfo: const QList<DriverInfo *> &): void
        -m_ListDriverInfo: QList<DriverInfo *>
    }

    class LoadInfoThread {
        +LoadInfoThread()
        +~LoadInfoThread()
    }
    LoadInfoThread --|> QThread

    class DeviceWidget {
        +DeviceWidget(parent: QWidget *)
        +~DeviceWidget()
    }
    DeviceWidget --|> DWidget

    class MainWindow {
        +slotSetPage(page: const QString &): void
    }

    class DeviceNetwork {
        +setInfoFromHwinfo(mapInfo: const QMap<QString, QString> &): bool
        -m_Name: QString
    }

    class DeviceMonitor {
        +subTitle(): QString
        -m_Name: QString
    }
Loading

File-Level Changes

Change Details Files
Update GPU memory info collection to use a new sysfs file and generic unit parsing while always reporting in GB.
  • Change GPU memory info source from gc/meminfo to gc/total_mem and update error messages accordingly
  • Replace SYSTEM0/Total-specific regex parsing with a generic number+unit regex
  • Convert parsed memory values from MB/GB/KB/B into a normalized GB string with two decimal places
  • Insert the computed total memory value into the graphics memory map entry
deepin-devicemanager-server/customgpuinfo/main.cpp
Fix Wake-on-LAN ioctl interface name initialization and struct setup for network devices.
  • Zero-initialize ethtool_wolinfo before use in both wake-on-LAN query and set functions
  • Convert logicalName to a local 8-bit QByteArray and safely copy into ifr.ifr_name using IFNAMSIZ-1 and explicit null-termination
  • Retain existing ethtool ioctl logic for querying and setting WoL options
deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp
Adjust monitor-related UI behavior and translations for special device types.
  • Add new translation entries for the "Monitor" label in the Chinese TS file with multiple source locations
  • Hide the device table for Monitor pages when specialComType >= 1 in PageMultiInfo::updateInfo
  • Skip table updates for Monitor pages when specialComType > 0 in PageMultiInfo::resizeEvent
deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts
deepin-devicemanager/src/Page/PageMultiInfo.cpp
Improve const-correctness and override usage in driver and threading interfaces.
  • Change DBusDriverInterface slots to take const QString/&QStringList references instead of by-value parameters
  • Update DriverScanner::setDriverList to take the driver list by const reference
  • Change CmdTool::parseOemTomlInfo to take filename by const QString reference
  • Mark CmdTask and LoadInfoThread destructors as override and adjust CmdTask constructor parameters to const references
  • Mark DeviceWidget destructor as override
deepin-devicemanager/src/DriverControl/DBusDriverInterface.cpp
deepin-devicemanager/src/DriverControl/DBusDriverInterface.h
deepin-devicemanager/src/DriverControl/DriverScanner.cpp
deepin-devicemanager/src/DriverControl/DriverScanner.h
deepin-devicemanager/src/GenerateDevice/CmdTool.cpp
deepin-devicemanager/src/GenerateDevice/CmdTool.h
deepin-devicemanager/src/GenerateDevice/GetInfoPool.h
deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp
deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h
deepin-devicemanager/src/Page/DeviceWidget.h
Refine device information handling for monitors and network devices.
  • Clear DeviceMonitor::m_Name in subTitle() when specialComType >= 1 to suppress monitor subtitles in special configurations
  • Set DeviceNetwork::m_Name from the "Device" field of hwinfo map if present to improve network device naming
  • Extend getMulHwinfoInfo network-device detection to treat devices whose name contains "WI-FI" (case-insensitive) as network devices
deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp
deepin-devicemanager/src/GenerateDevice/CmdTool.cpp
Minor slot signature cleanup in main window navigation.
  • Change MainWindow::slotSetPage to take page by const QString reference in both declaration and definition
deepin-devicemanager/src/Page/MainWindow.cpp
deepin-devicemanager/src/Page/MainWindow.h

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

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

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `deepin-devicemanager-server/customgpuinfo/main.cpp:83-90` </location>
<code_context>
+    double value = memInfoMatch.captured(1).toDouble();
+    QString unit = memInfoMatch.captured(2).toUpper();
+
+    if (unit == "MB") {
+        totalValue = QString("%1GB").arg(value / 1024.0, 0, 'f', 2);
+    } else if (unit == "GB") {
+        totalValue = QString("%1GB").arg(value, 0, 'f', 2);
+    } else if (unit == "KB") {
+        totalValue = QString("%1GB").arg(value / (1024.0 * 1024.0), 0, 'f', 2);
+    } else if (unit == "B") {
+        totalValue = QString("%1GB").arg(value / (1024.0 * 1024.0 * 1024.0), 0, 'f', 2);
     }

</code_context>

<issue_to_address>
**question (bug_risk):** Recheck the unit conversion and formatting semantics against previous behavior

Previously we only formatted as GB (integer) when `memSize >= 1 GiB` (with `memSize` in KiB); otherwise we showed MB. The new code always emits a fractional GB value, even for small sizes.

If callers of `kGraphicsMemory` rely on MB for <1 GB or on integer values, this is a behavioral change that could cause UI/logic issues. Either keep the old MB/GB cutoff behavior or confirm all consumers can handle fractional GB in all cases.

Also verify whether `/sys/kernel/debug/gc/total_mem` reports binary units (KiB/MiB/GiB) or SI (KB/MB/GB), and ensure the conversion (1024 vs 1000) matches that.
</issue_to_address>

### Comment 2
<location> `deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp:381-382` </location>
<code_context>
 QString DeviceMonitor::subTitle()
 {
     // qCDebug(appLog) << "Getting monitor subtitle";
+    if (Common::specialComType >= 1) {
+        m_Name.clear();
+    }
     return m_Name;
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Clearing `m_Name` on every `subTitle()` call may introduce subtle state issues

This change makes `subTitle()` mutate object state whenever `specialComType >= 1`, which can unexpectedly erase `m_Name` set elsewhere (e.g., on initialization or monitor changes) and complicate reasoning about the class. If the goal is just to hide the subtitle, prefer returning an empty string without modifying the member:

```cpp
if (Common::specialComType >= 1)
    return QString();
return m_Name;
```

That keeps `m_Name` as the stored value while the UI logic decides when to show it.
</issue_to_address>

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.

lzwind
lzwind previously approved these changes Dec 1, 2025
GongHeng2017 and others added 4 commits December 1, 2025 14:38
-- unused parameter
-- implicit conversion turns floating-point number into integer: 'double' to 'int'
-- 9 enumeration values not handled in switch: 'ST_CAN_UPDATE', 'ST_WAITING', 'ST_DRIVER_NOT_BACKUP'...
-- Function parameter 'status' should be passed by const reference

pick from: linuxdeepin@61ad67e
…ation

- Add isHwPlatform() method to Common class for platform type checking
- Implement getMonitorNameFromEdid() in DeviceMonitor for EDID parsing
- Add monitor name validation logic in setInfoFromXradr() method
- Skip monitor name validation on non-hardware platforms
- Enhance monitor device detection accuracy by comparing EDID monitor names

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-330145.html
- Use case-insensitive contains matching instead of exact string
comparison
- Support interface name variations like 'ps/2', 'bluetooth low energy',
etc.
- Refactor hardcoded interface checks to use static list and loop
- Fix device availability detection for input devices with non-standard
interface names

pick from: linuxdeepin@b8c68ae

Log: Improve input device Bus interface detection
Bug: https://pms.uniontech.com/bug-view-331181.html
Change-Id: Ifbc7c40f44f45e146f07fe101ed3fc960e945459
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这次代码变更进行审查:

  1. GPU内存信息获取优化(main.cpp)
  • 优点:
    • 简化了内存信息解析逻辑,使用单一正则表达式匹配
    • 统一了内存单位转换逻辑,支持MB/GB/KB/B多种单位
  • 建议:
    • 可以添加对内存值的范围检查,防止异常值
    • 可以考虑添加对单位大小写不敏感的处理
  1. 网络设备唤醒控制优化(wakeuputils.cpp)
  • 优点:
    • 修复了字符串拷贝的潜在缓冲区溢出问题
    • 使用IFNAMSIZ限制长度,确保安全性
    • 添加了内存初始化,更安全
  • 建议:
    • 可以考虑使用strncpy_s等更安全的字符串函数
  1. 输入设备接口判断优化(DeviceInput.cpp/h)
  • 优点:
    • 使用静态列表存储支持的接口类型
    • 使用Qt的contains函数进行大小写不敏感比较
  • 建议:
    • 考虑将m_supportInterfaces声明为const
  1. 显示器设备信息处理优化(DeviceMonitor.cpp/h)
  • 优点:
    • 添加了显示器名称验证
    • 改进了特殊型号处理逻辑
  • 建议:
    • getMonitorNameFromEdid函数可以添加错误处理
  1. 网络设备信息处理优化(DeviceNetwork.cpp)
  • 优点:
    • 添加了设备名称获取
  • 建议:
    • 可以添加对设备名称的格式验证
  1. DBus接口优化(DBusDriverInterface.cpp/h)
  • 优点:
    • 将参数改为const引用,提高效率
    • 改进了类型安全性
  • 建议:
    • 可以添加更多的参数有效性检查
  1. 驱动扫描器优化(DriverScanner.cpp/h)
  • 优点:
    • 参数改为const引用,提高效率
  • 建议:
    • 可以添加对驱动列表的空值检查
  1. 命令工具优化(CmdTool.cpp/h)
  • 优点:
    • 改进了音频和网络设备的识别逻辑
    • 添加了更多的设备类型支持
  • 建议:
    • 可以添加对关键操作的异常处理
  1. 界面相关优化
  • 优点:
    • 添加了更多设备类型的支持
    • 改进了内存和显示设备的处理
    • 修复了一些潜在的类型转换问题
  • 建议:
    • 可以添加更多的用户输入验证
  1. 通用功能优化(commonfunction.cpp/h)
  • 优点:
    • 添加了平台类型判断函数
    • 改进了参数类型安全性
  • 建议:
    • 可以添加更多的错误处理

总体评价:

  1. 代码质量有显著提升,主要体现在:
    • 更好的类型安全性
    • 更安全的字符串处理
    • 更完善的设备支持
  2. 性能方面:
    • 使用const引用减少拷贝
    • 优化了正则表达式匹配
  3. 安全性方面:
    • 修复了缓冲区溢出风险
    • 添加了更多的参数检查
  4. 建议改进:
    • 添加更多的错误处理和异常捕获
    • 增加关键操作的日志记录
    • 考虑添加单元测试
    • 可以考虑使用更现代的C++特性

这次变更整体上是积极的,提高了代码的健壮性和可维护性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos
Copy link
Contributor Author

add-uos commented Dec 1, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 1, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit f6f6aac into linuxdeepin:master Dec 1, 2025
15 of 18 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.

4 participants