fix(dock): debounce tray plugin list logging to ensure stable state#1597
fix(dock): debounce tray plugin list logging to ensure stable state#1597Ivy233 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 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 |
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.
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
248ac3d to
f8b4b72
Compare
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff。本次修改主要涉及Debian打包依赖版本的调整,以及对Dock插件状态日志记录逻辑的重构(引入了防抖机制)。 总体而言,将原本的固定延时日志改为基于事件驱动的防抖日志是一个很好的优化,可以避免在插件频繁变动时产生冗余日志。但在代码逻辑、性能和安全方面,还有一些可以改进的空间。以下是详细的审查意见: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进后的代码建议panels/dock/dockdbusproxy.cpp // ... 前面代码保持不变 ...
connect(m_trayApplet, &DS_NAMESPACE::DAppletProxy::pluginsChanged, this, &DockDBusProxy::pluginsChanged);
// 采用防抖机制记录初始状态
connect(this, &DockDBusProxy::pluginsChanged, this, [this]() {
scheduleDebouncedLog();
});
scheduleDebouncedLog(); // 触发首次防抖计时
// ... 前面代码保持不变 ...
void DockDBusProxy::scheduleDebouncedLog()
{
if (!m_debounceTimer) {
m_debounceTimer = new QTimer(this);
m_debounceTimer->setSingleShot(true);
m_debounceTimer->setInterval(2000);
// 使用函数指针替代 Lambda,更简洁高效
connect(m_debounceTimer, &QTimer::timeout, this, &DockDBusProxy::logInitialPluginState);
}
m_debounceTimer->start();
}debian/control (请务必复核版本号) 希望这些审查意见对你有所帮助!如果有任何疑问,欢迎随时提问。 |
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。
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: