fix(dock): debounce tray plugin list logging to ensure stable state#1597
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaces the fixed 3‑second delayed logging of tray plugin lists with a debounced logging mechanism triggered by plugin change events, and adjusts dde-application-manager packaging dependencies. Sequence diagram for debounced tray plugin list loggingsequenceDiagram
participant TrayApplet
participant DockDBusProxy
participant DebounceTimer
TrayApplet->>DockDBusProxy: pluginsChanged()
DockDBusProxy->>DockDBusProxy: scheduleDebouncedLog()
alt first_call_or_timer_not_created
DockDBusProxy->>DebounceTimer: create QTimer
DockDBusProxy->>DebounceTimer: setSingleShot(true)
DockDBusProxy->>DebounceTimer: setInterval(2000)
DebounceTimer-->>DockDBusProxy: timeout (connected to logInitialPluginState)
end
DockDBusProxy->>DebounceTimer: start()
rect rgb(230,230,230)
Note over DebounceTimer: 2s debounce window
end
DebounceTimer-->>DockDBusProxy: timeout
DockDBusProxy->>DockDBusProxy: logInitialPluginState()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider extracting the hardcoded 2000 ms debounce interval into a named constant or configuration value so the debounce behavior is easier to adjust and understand in the future.
- The QTimer timeout connection in
scheduleDebouncedLoguses a lambda that simply callslogInitialPluginState; replacing this with a direct slot connection would simplify the code and avoid an extra indirection.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the hardcoded 2000 ms debounce interval into a named constant or configuration value so the debounce behavior is easier to adjust and understand in the future.
- The QTimer timeout connection in `scheduleDebouncedLog` uses a lambda that simply calls `logInitialPluginState`; replacing this with a direct slot connection would simplify the code and avoid an extra indirection.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
248ac3d to
f8b4b72
Compare
f8b4b72 to
2e5d44d
Compare
2e5d44d to
9c5da97
Compare
延长托盘插件列表日志记录延时以等待插件完全加载 PMS: BUG-361067
9c5da97 to
0e36585
Compare
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff,本次修改主要涉及Debian打包控制文件和DDE Dock的DBus代理代码。 以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的详细审查意见和改进建议: 1. 语法与逻辑debian/control 依赖版本逻辑冲突(高优先级)在
问题:编译时允许 延时逻辑的可靠性将 2. 代码质量魔法数字代码中使用了 static constexpr int INITIAL_PLUGIN_LOG_DELAY_MS = 30000; // 30 seconds
QTimer::singleShot(INITIAL_PLUGIN_LOG_DELAY_MS, this, [this]() {
logInitialPluginState();
});注释质量新增的注释 3. 代码性能启动耗时与资源占用问题:30秒的延时虽然不阻塞主线程(因为用了
4. 代码安全本次修改在安全方面风险较低,但有两点需要注意: 时间盲点引发的竞态条件问题:在30秒的等待期间,如果插件列表发生了变化(触发了 Lambda生命周期安全问题: 改进后的代码建议针对 // 在头文件或cpp文件顶部定义常量
static constexpr int INITIAL_PLUGIN_LOG_DELAY_MS = 30000; // 30s: 等待慢速机器插件列表完全加载
// ... 构造函数内部 ...
timer->stop();
timer->deleteLater();
connect(m_trayApplet, SIGNAL(pluginsChanged()), this, SIGNAL(pluginsChanged()));
// TODO: 未来如果 TrayApplet 提供了 loaded() 信号,应替换此定时器方案
QTimer::singleShot(INITIAL_PLUGIN_LOG_DELAY_MS, this, [this]() {
if (m_trayApplet) { // 确保 m_trayApplet 依然有效
logInitialPluginState();
}
});对于 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233, 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Replace fixed 3-second delay with debounce mechanism for tray plugin list event logging. The original approach reported plugin state immediately upon tray applet connection and again after a fixed 3-second delay, which could capture incomplete plugin lists during login.
Use a 2-second debounce timer that resets on each
pluginsChanged signal, ensuring the log only records the final stable plugin list. Also adjust dde-application- manager packaging dependencies.
将托盘插件列表事件上报从固定3秒延迟改为防抖机制。
原始方案在托盘小程序连接后立即上报并延迟3秒再报一次,
在登录时可能捕获到不完整的插件列表。
改用2秒防抖定时器,每次插件列表变化时重置,
确保只记录最终稳定的插件列表。同时调整
dde-application-manager 打包依赖。
PMS: BUG-361067
PS: 打包依赖是dde-am修改的时候,依赖调整,如果需要单独提pr就comment一下。调整pr原因:
版本号来源:linuxdeepin/dde-application-manager#354
依赖修改对应pr:#1590
Summary by Sourcery
Debounce logging of the dock tray plugin list so it records only the final stable state after plugin changes.
Bug Fixes:
Enhancements:
Build: