Skip to content

fix: fix building warnings.#352

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-build-warning
Aug 18, 2025
Merged

fix: fix building warnings.#352
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-build-warning

Conversation

@wjyrich

@wjyrich wjyrich commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

as titile.

Logs:

Summary by Sourcery

Add Q_UNUSED macros and remove unnecessary qualifiers to suppress build warnings across loader and plugin modules

Enhancements:

  • Suppress compiler warnings by marking unused parameters with Q_UNUSED in various event filters and plugin methods
  • Remove redundant const qualifiers from simple inline getters to clean up signatures
  • Reorder constructor initializer lists to match member declaration order and resolve initialization warnings

Chores:

  • Fix build warnings across multiple components by silencing unused parameters and correcting method signatures

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

代码审查报告

总体评价

这是一系列关于Deepin Dock插件的代码修改,主要集中在添加Q_UNUSED宏来标记未使用的参数。这些修改有助于提高代码质量,消除编译器警告,并表明开发者有意忽略某些参数。

具体分析

1. 语法逻辑

  • 所有修改都遵循了正确的语法规则
  • Q_UNUSED宏的使用方式正确,确保未使用参数不会产生编译器警告
  • 函数签名和实现保持一致

2. 代码质量

  • 优点:

    • 统一使用Q_UNUSED处理未使用参数,提高代码一致性
    • 明确标识未使用参数,便于后续维护
    • 消除了编译器警告,使代码更加整洁
  • 改进建议:

    • 某些函数如refreshIconitemContextMenu可能需要实际实现,而不仅仅是标记参数未使用
    • 考虑添加注释说明为什么某些参数未被使用

3. 代码性能

  • 这些修改对性能没有明显影响
  • Q_UNUSED宏在编译时处理,不会影响运行时性能

4. 代码安全

  • 修改不会引入新的安全问题
  • 正确使用Q_UNUSED有助于避免意外使用未初始化的参数

具体改进建议

  1. 函数实现改进

    // 当前
    void MediaPlugin::refreshIcon(const QString &itemKey)
    {
        Q_UNUSED(itemKey)
    }
    
    // 建议
    void MediaPlugin::refreshIcon(const QString &itemKey)
    {
        Q_UNUSED(itemKey)
        // 实现实际的图标刷新逻辑
    }
  2. 添加注释说明

    void EyeComfortModeController::enable(bool enable)
    {
        Q_UNUSED(enable) // 此参数保留以保持接口一致性,实际使用内部状态
        m_displayInter->setProperty(COLOR_TEMPERATURE_ENABLED, !isEyeComfortModeEnabled());
    }
  3. 考虑重构
    对于多个地方使用相同模式处理未使用参数的情况,可以考虑使用宏或模板来减少重复代码:

    #define UNUSED_IF_NO_IMPL(func) \
    void func { \
        Q_UNUSED(itemKey) \
        /* TODO: 实际实现 */ \
    }
  4. 常量成员函数
    一些获取函数应该标记为const:

    // 当前
    bool isExpand() { return m_isExpand; }
    
    // 建议
    bool isExpand() const { return m_isExpand; }

总结

这些修改总体上是积极的,提高了代码质量并消除了编译器警告。建议在保持这些修改的基础上,进一步完善函数实现,添加必要的注释,并考虑使用const标记适当的成员函数。对于暂时未实现的函数,建议添加TODO注释以便后续跟踪。

@sourcery-ai

sourcery-ai Bot commented Aug 18, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR systematically silences compiler warnings by marking unused parameters and variables with Q_UNUSED, refines inline getter signatures, and corrects constructor initializer lists to match member order, improving code consistency and eliminating build-time warnings.

Class diagram for updated getter signatures and member order

classDiagram
    class MonitorItemDelegate {
        +int expandItemHeight() const
        +int standardItemHeight() const
        +int itemSpacing() const
    }
    class PluginItemDelegate {
        +int itemHeight() const
        +int itemSpacing() const
        +void setItemHeight(int height)
        +void setItemSpacing(int spacing)
    }
    class DeviceControlWidget {
        +bool isExpand()
        +void expandStateChanged(bool state)
    }
    class Monitor {
        +bool canBrightness() const
    }
Loading

Class diagram for PluginItem member order change

classDiagram
    class PluginItem {
        QString m_itemKey
        PluginsItemInterface *m_pluginsItemInterface
        QMenu *m_menu
        QScopedPointer<DockDBusProxy> m_dbusProxy
        QTimer* m_tooltipTimer
        QPointer<QWidget> m_tipsWidget
    }
Loading

File-Level Changes

Change Details Files
Suppress unused parameter warnings
  • Added Q_UNUSED for unused function parameters across core loader and plugin classes
  • Inserted Q_UNUSED in paintEvent, eventFilter, and lambda callbacks
  • Marked unused Qt signal and D-Bus callback arguments with Q_UNUSED
src/loader/widgetplugin.cpp
plugins/dde-dock/media/mediaplugin.cpp
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/widget/monitoritemdelegate.h
plugins/dde-dock/keyboard-layout/dbusadaptors.cpp
plugins/application-tray/abstracttrayprotocol.h
plugins/dde-dock/common/pluginitemdelegate.h
plugins/dde-network-display-ui/plugins/common/wirelesscastingmodel.cpp
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/wirelesscastingplugin.cpp
plugins/dde-dock/airplane-mode/airplanemodeplugin.cpp
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.h
plugins/dde-dock/eye-comfort-mode/eyecomfortmodecontroller.cpp
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/wirelesscastingapplet.cpp
src/loader/pluginitem.cpp
src/loader/pluginitem.h
src/loader/quickpluginitem.cpp
plugins/application-tray/sniprotocolhandler.cpp
plugins/application-tray/trayplugin.cpp
plugins/application-tray/traywidget.cpp
plugins/application-tray/xembedprotocolhandler.cpp
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp
plugins/dde-dock/brightness/brightnesscontroller.cpp
plugins/dde-dock/notification/notificationplugin.cpp
plugins/dde-dock/notification/notification.cpp
plugins/dde-dock/sound/soundcontroller.cpp
plugins/dde-dock/sound/soundquickpanel.cpp
plugins/dde-dock/widgets/singlecontentwidget.h
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/displaymodel.cpp
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/wirelesscastingitem.cpp
src/loader/main.cpp
Normalize inline getter signatures
  • Removed redundant 'const' qualifiers on primitive return types
  • Simplified inline accessor methods in delegate and data classes
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/widget/monitoritemdelegate.h
plugins/dde-dock/common/pluginitemdelegate.h
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.h
plugins/dde-dock/brightness/monitor.h
Fix constructor initialization order
  • Reordered initializer lists to match class member declaration order
  • Moved m_menu initialization after m_inputmethod in DBusAdaptors
  • Adjusted PluginItem initializer ordering to prevent warnings
plugins/dde-dock/keyboard-layout/dbusadaptors.cpp
src/loader/pluginitem.cpp
Refine abstract protocol handler signature
  • Added Q_UNUSED to parameters in AbstractTrayProtocolHandler constructor
  • Marked unused arguments in the virtual eventFilter override
plugins/application-tray/abstracttrayprotocol.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

@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 there - I've reviewed your changes - here's some feedback:

  • Consider omitting parameter names in empty override definitions (e.g. void func(int) {}) or using [[maybe_unused]] instead of sprinkling Q_UNUSED everywhere to reduce noise and improve readability.
  • Make sure initializer lists match the member declaration order in all classes to avoid warnings and keep the code consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider omitting parameter names in empty override definitions (e.g. void func(int) {}) or using [[maybe_unused]] instead of sprinkling Q_UNUSED everywhere to reduce noise and improve readability.
- Make sure initializer lists match the member declaration order in all classes to avoid warnings and keep the code consistent.

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

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

@wjyrich

wjyrich commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Aug 18, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 7b1f86b into linuxdeepin:master Aug 18, 2025
7 of 9 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