Skip to content

Conversation

@pengfeixx
Copy link

@pengfeixx pengfeixx commented Jan 20, 2026

Fix Linglong upgrade repeatedly sending remove signal

Log: Fix Linglong upgrade repeatedly sending remove signal
pms: BUG-340923

Summary by Sourcery

Bug Fixes:

  • Reduce repeated Linglong upgrade remove signals by lengthening the application reload timer interval.

Fix Linglong upgrade repeatedly sending remove signal

Log: Fix Linglong upgrade repeatedly sending remove signal
pms: BUG-340923
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Increases the debounce interval for the application reload timer to reduce repeated Linglong upgrade removal signals.

Sequence diagram for debounced Linglong upgrade application reload

sequenceDiagram
    actor Linglong
    participant ApplicationManager1Service
    participant QTimer_m_reloadTimer as QTimer_m_reloadTimer
    participant ApplicationStore

    Linglong->>ApplicationManager1Service: notifyUpgradeEvent()
    ApplicationManager1Service->>QTimer_m_reloadTimer: start(interval=500ms, singleShot=true)

    Linglong->>ApplicationManager1Service: notifyUpgradeEvent()
    ApplicationManager1Service->>QTimer_m_reloadTimer: restart(interval=500ms)

    Linglong->>ApplicationManager1Service: notifyUpgradeEvent()
    ApplicationManager1Service->>QTimer_m_reloadTimer: restart(interval=500ms)

    QTimer_m_reloadTimer-->>ApplicationManager1Service: timeout()
    ApplicationManager1Service->>ApplicationStore: doReloadApplications()
    ApplicationStore-->>ApplicationManager1Service: reloadCompleted()
Loading

Updated class diagram for ApplicationManager1Service reload timer debounce

classDiagram
    class ApplicationManager1Service {
        - QTimer m_reloadTimer
        + ApplicationManager1Service(IdentifierManager identifierManager, QObject parent)
        + void doReloadApplications()
    }

    class QTimer {
        + void setInterval(int msec)
        + void setSingleShot(bool singleShot)
        + void start()
        + void stop()
        + signal timeout()
    }

    ApplicationManager1Service --> QTimer : uses m_reloadTimer

    note for ApplicationManager1Service "m_reloadTimer interval increased from 50ms to 500ms to reduce repeated remove signals"
Loading

File-Level Changes

Change Details Files
Increase reload timer interval to debounce application reloads more aggressively.
  • Update QTimer interval from 50 ms to 500 ms to space out reload operations.
  • Keep the timer as single-shot and still bound to doReloadApplications on timeout.
src/dbus/applicationmanager1service.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

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

deepin pr auto review

这段代码修改将 QTimer 的超时间隔从 50 毫秒调整为 500 毫秒。以下是对该修改的审查意见,涵盖逻辑、质量、性能和安全四个方面:

1. 语法逻辑

  • 审查结果:通过。
  • 分析:代码语法正确,符合 Qt/C++ 编码规范。setInterval 接受毫秒为单位的整数参数,修改后的值 500 在合法范围内。

2. 代码质量

  • 审查结果:改进建议。
  • 分析
    • 硬编码:代码中直接使用了字面量 500。虽然修改为 500 提高了可读性(相比 50),但为了更好的可维护性,建议将其定义为具有语义名称的常量(例如 kReloadDelayMskDebounceIntervalMs)。
    • 意图明确:从 50 改为 500 显著改变了定时器的行为。这通常意味着从"高频轮询/快速响应"转变为"防抖动/延迟处理"。建议在代码注释中明确说明为什么选择 500ms(例如:为了合并短时间内频繁触发的重载请求)。

3. 代码性能

  • 审查结果:显著提升。
  • 分析
    • 减少 CPU 占用:将间隔从 50ms 增加到 500ms,意味着在 doReloadApplications 被触发前,系统有更长的缓冲时间来收集多次状态变更。如果 doReloadApplications 是一个资源密集型操作(如扫描文件系统、解析大量元数据),这种修改能极大减少其在短时间内的重复执行次数。
    • 防抖动效果:配合 setSingleShot(true),如果该定时器被用于处理快速连续的事件(如文件系统变更通知),500ms 的间隔能有效地将多次触发合并为一次执行,从而显著提升整体性能。

4. 代码安全

  • 审查结果:无直接影响。
  • 分析:此修改主要涉及定时器频率,不涉及内存管理、权限控制或外部输入处理,因此不会直接引入安全漏洞。

综合改进建议

虽然当前的修改在功能上是正确的,但为了提高代码的健壮性和可维护性,建议进行以下优化:

// 在类定义或匿名命名空间中定义常量
namespace {
    constexpr int kReloadDebounceIntervalMs = 500; // 定义防抖动间隔
}

// 构造函数中的使用
ApplicationManager1Service::ApplicationManager1Service(std::unique_ptr<Identifier> identifier)
    : ApplicationManager1(std::move(identifier))
{
    // ... 其他代码 ...

    // 使用常量替代字面量,并添加注释说明意图
    // 设置 500ms 的延迟以合并短时间内频繁触发的重载请求(防抖动)
    m_reloadTimer.setInterval(kReloadDebounceIntervalMs);
    m_reloadTimer.setSingleShot(true);
    connect(&m_reloadTimer, &QTimer::timeout, this, &ApplicationManager1Service::doReloadApplications);
}

总结:将间隔调整为 500ms 是一个合理的性能优化,特别是在处理频繁触发的重载事件时。建议通过定义常量和添加注释来进一步提升代码质量。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ComixHe, pengfeixx

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

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