From 2ac43721456c24269d5c2ae649518aa3e3c8e6eb Mon Sep 17 00:00:00 2001 From: wangjinrun Date: Thu, 22 Oct 2026 13:04:58 +0800 Subject: [PATCH] fix(notification): use reschedule() instead of onTimeout() in push/remove/setBlockId to prevent repeated popup When a notification replaces an existing one (push), is removed (remove), or has its block ID changed (setBlockId), the code incorrectly called onTimeout(). This caused the timer's timeout handler to fire, which emits the expired signal for the nearest-deadline notification, closing its bubble. The bubble then gets re-created, appearing as a repeated popup. Fix: extract the timer-rescheduling logic from onTimeout() into a new reschedule() method. Call reschedule() instead of onTimeout() in push(), remove(), and setBlockId() so the timer is adjusted without triggering premature expiration. --- panels/notification/common/expiretimer.cpp | 12 ++++++++---- panels/notification/common/expiretimer.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/panels/notification/common/expiretimer.cpp b/panels/notification/common/expiretimer.cpp index c72858462..15a20c6f4 100644 --- a/panels/notification/common/expiretimer.cpp +++ b/panels/notification/common/expiretimer.cpp @@ -68,7 +68,7 @@ void ExpireTimer::push(const NotifyEntity &entity) m_pendingEntities.erase(iter); if (m_blockId == oldId) m_blockId = id; - onTimeout(); + reschedule(); break; } } @@ -97,7 +97,7 @@ void ExpireTimer::remove(qint64 id) if (iter.value().id() != id) continue; m_pendingEntities.erase(iter); - onTimeout(); + reschedule(); return; } } @@ -124,7 +124,7 @@ void ExpireTimer::setBlockId(qint64 id) } m_blockId = id; - onTimeout(); + reschedule(); } void ExpireTimer::onTimeout() @@ -159,7 +159,11 @@ void ExpireTimer::onTimeout() Q_EMIT expired(item.id(), item.bubbleId()); } - // Reschedule for the nearest remaining deadline. + reschedule(); +} + +void ExpireTimer::reschedule() +{ if (m_pendingEntities.isEmpty()) { m_timer->stop(); m_lastPoint = std::numeric_limits::max(); diff --git a/panels/notification/common/expiretimer.h b/panels/notification/common/expiretimer.h index 42d8f5f37..6e3e2d1f5 100644 --- a/panels/notification/common/expiretimer.h +++ b/panels/notification/common/expiretimer.h @@ -56,6 +56,7 @@ class ExpireTimer : public QObject explicit ExpireTimer(QObject *parent = nullptr); void onTimeout(); + void reschedule(); QTimer *m_timer = nullptr; // Pending entities keyed by absolute expire deadline (ms since the epoch);