Skip to content

pick develop/eagle to master#571

Merged
deepin-bot[bot] merged 5 commits intolinuxdeepin:masterfrom
add-uos:master
Dec 1, 2025
Merged

pick develop/eagle to master#571
deepin-bot[bot] merged 5 commits intolinuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos
Copy link
Contributor

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

pick develop/eagle to master

GongHeng2017 and others added 5 commits December 1, 2025 14:55
-- Funtion  parameter should be passed by const reference.
-- Unused parameter.
-- The scope of the varible 'index' can reduced.

pick from: linuxdeepin@76729e9
improve input device Bus interface detectionadd, add input device bus
interface for USB Devices

Log: add input device bus interface for USB Devices
Bug: https://pms.uniontech.com/bug-view-331181.html
Change-Id: Ie66f434275af797a31a083f9ea6eb8a63dd427ab
…with USB headphones

Fixed an issue where Device Manager's audio enable/disable functionality
briefly toggled audio device states during initialization, causing USB
headphone playback to pause. This occurred due to temporary audio device
state switching logic during the initial setup phase.

Log: Fix USB audio playback interruption from Device Manager
Bug: https://pms.uniontech.com/bug-view-332095.html
Change-Id: Idd98f8cd92884d3f7b7297adf64901c49f9807a0
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.

Sorry @add-uos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link

deepin pr auto review

我来分析这些代码变更并提供改进建议:

  1. main.cpp 中的修改:
-    if (getGpuBaseInfo(mapInfo) && getGpuMemInfoForFTDTM(mapInfo)) {
+    if (getGpuBaseInfo(mapInfo)) {
+        getGpuMemInfoForFTDTM(mapInfo);

改进建议:

  • 这个修改降低了代码的健壮性。原代码要求两个函数都必须成功执行,而新代码即使 getGpuMemInfoForFTDTM 失败也会继续执行。
  • 建议改为:
if (getGpuBaseInfo(mapInfo)) {
    if (!getGpuMemInfoForFTDTM(mapInfo)) {
        qWarning() << "Failed to get GPU memory info";
    }
    // 继续执行其他代码
}
  1. DeviceInput.cpp 中的修改:
-QStringList DeviceInput::m_supportInterfaces= {"PS/2", "Bluetooth", "I2C"};
+QStringList DeviceInput::m_supportInterfaces= {"PS/2", "Bluetooth", "I2C", "USB"};

改进建议:

  • 这个修改是合理的,增加了对USB接口的支持。
  • 建议考虑将这个列表定义为const:
const QStringList DeviceInput::m_supportInterfaces = {"PS/2", "Bluetooth", "I2C", "USB"};
  1. DeviceManager.cpp 中的修改:
+        qDebug() << enabledDevices.value(it)->name() << "is enable: " << enabledDevices.value(it)->enable();
+        if (enabledDevices.value(it)->enable()){
+            continue;
+        }

改进建议:

  • 添加了调试日志是好的,但应该使用条件编译来控制调试输出:
#ifdef QT_DEBUG
        qDebug() << enabledDevices.value(it)->name() << "is enable: " << enabledDevices.value(it)->enable();
#endif
  • 逻辑判断可以优化,避免重复调用value():
auto device = enabledDevices.value(it);
if (device->enable()) {
    continue;
}
  1. CmdTool.cpp 中的修改:
-        if (mapInfo["Hardware Class"] == "sound"
-                || (mapInfo["Device"].contains("USB Audio") && mapInfo["Device"].contains("snd-usb-audio"))
-                || mapInfo["Driver"].contains("snd-usb-audio")) {
+        if (mapInfo["Hardware Class"] == "sound" || (mapInfo["Device"].contains("USB Audio") && mapInfo["Device"].contains("snd-usb-audio"))) {

改进建议:

  • 这个修改移除了对Driver的检查,可能会遗漏某些设备。建议保留原有的检查逻辑,但可以优化写法:
if (mapInfo["Hardware Class"] == "sound" 
    || (mapInfo["Device"].contains("USB Audio") && mapInfo["Device"].contains("snd-usb-audio"))
    || mapInfo["Driver"].contains("snd-usb-audio")) {
  1. PageDriverControl.h/cpp 中的修改:
-    PageDriverControl(QWidget *parent, QString operation, bool install, QString deviceName, QString driverName, QString printerVendor, QString printerModel)
+    PageDriverControl(QWidget *parent, const QString &operation, bool install, const QString &deviceName, const QString &driverName, const QString &printerVendor, const QString &printerModel)

改进建议:

  • 将QString参数改为const引用是好的实践,可以避免不必要的拷贝。
  • 同样的改进也应用到了其他函数参数,这是正确的做法。
  1. PageDriverManager.h/cpp 中的修改:
+    Q_UNUSED(itemIndex)
+    Q_UNUSED(progress)
+    Q_UNUSED(strDeatils)
+    Q_UNUSED(msg)

改进建议:

  • 使用Q_UNUSED标记未使用的参数是好的做法,但更好的做法是重新审视这些函数的设计,看是否真的需要这些参数。
  • 如果这些参数确实不需要,可以考虑从函数签名中移除。
  1. PageListView.h/cpp 中的修改:
-    void setCurType(QString type);
+    void setCurType(const QString &type);

改进建议:

  • 将参数改为const引用是正确的做法,符合Qt的最佳实践。

总体建议:

  1. 代码中多处添加了const修饰符,这是好的改进。
  2. 调试输出应该使用条件编译控制。
  3. 一些函数参数的必要性需要重新评估。
  4. 错误处理逻辑需要更加完善。
  5. 代码中的一些重复调用可以优化。
  6. 建议添加更多的错误检查和日志记录。

@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 d7c14e8 into linuxdeepin:master Dec 1, 2025
15 of 17 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