From f8b4b7255cf5f51f42f3e9df14c8a6343cfd8f4a Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Thu, 14 May 2026 21:24:26 +0800 Subject: [PATCH] fix(dock): debounce tray plugin list logging to ensure stable state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- debian/control | 3 ++- panels/dock/dockdbusproxy.cpp | 20 ++++++++++++++++++-- panels/dock/dockdbusproxy.h | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index 306c26b3c..3a61f09ce 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: Deepin Packages Builder Build-Depends: debhelper-compat (= 13), cmake, - dde-application-manager-api (>> 1.2.51), + dde-application-manager-api (>= 1.2.48), dde-api-dev (>> 6.0.39), dde-tray-loader-dev (> 2.0.24), extra-cmake-modules, @@ -82,6 +82,7 @@ Depends: qml6-module-qtquick-layouts, qml6-module-qtquick-window, qt6-wayland (>= 6.8), + dde-application-manager (>> 1.2.51), ${misc:Depends}, ${shlibs:Depends}, Breaks: diff --git a/panels/dock/dockdbusproxy.cpp b/panels/dock/dockdbusproxy.cpp index b321df5f4..ecad8a9af 100644 --- a/panels/dock/dockdbusproxy.cpp +++ b/panels/dock/dockdbusproxy.cpp @@ -81,9 +81,11 @@ DockDBusProxy::DockDBusProxy(DockPanel* parent) timer->stop(); timer->deleteLater(); connect(m_trayApplet, SIGNAL(pluginsChanged()), this, SIGNAL(pluginsChanged())); - QTimer::singleShot(3000, this, [this]() { - logInitialPluginState(); + // Trigger a debounced log on each change, and also schedule one immediately after first load + connect(this, &DockDBusProxy::pluginsChanged, this, [this]() { + scheduleDebouncedLog(); }); + scheduleDebouncedLog(); } }); timer->start(); @@ -301,6 +303,20 @@ void DockDBusProxy::logCurrentVisiblePluginList(const QString &changedItemKey, b #endif } +// Restart the timer on every pluginsChanged; only log after the list stays stable for 2s +void DockDBusProxy::scheduleDebouncedLog() +{ + if (!m_debounceTimer) { + m_debounceTimer = new QTimer(this); + m_debounceTimer->setSingleShot(true); + m_debounceTimer->setInterval(2000); + connect(m_debounceTimer, &QTimer::timeout, this, [this]() { + logInitialPluginState(); + }); + } + m_debounceTimer->start(); +} + void DockDBusProxy::ReloadPlugins() { parent()->ReloadPlugins(); diff --git a/panels/dock/dockdbusproxy.h b/panels/dock/dockdbusproxy.h index 455c26fc1..d2bd1b8dd 100644 --- a/panels/dock/dockdbusproxy.h +++ b/panels/dock/dockdbusproxy.h @@ -91,8 +91,12 @@ class DockDBusProxy final: public QObject, public QDBusContext void updateDockPluginsVisible(const QVariantMap &pluginsVisible); void logInitialPluginState(); void logCurrentVisiblePluginList(const QString &changedItemKey = QString(), bool changedVisible = true); + // Debounce logging the initial plugin list, as it may change asynchronously right after load + void scheduleDebouncedLog(); DS_NAMESPACE::DAppletProxy *m_oldDockApplet; DS_NAMESPACE::DAppletProxy *m_trayApplet; + // Debounce timer to ensure the plugin list has stabilized before logging + QTimer *m_debounceTimer = nullptr; }; }