From e1388789ffc5239587f88ec29bc0fa83bbeadfa3 Mon Sep 17 00:00:00 2001 From: Martin Klapetek Date: Fri, 1 May 2015 14:54:47 +0200 Subject: [PATCH] [notifications] Clear notification from show queue if it's closed before it's shown It can happen that a notification is placed in the show queue and then it's closed (eg. programatically) before it was even shown. In this case the notification must be cleared from the show queue otherwise it will get displayed and hidden but the popup is never freed for reuse, resulting in notificaions starting at higher position from the panel. BUG: 342605 --- .../notifications/plugin/notificationshelper.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/applets/notifications/plugin/notificationshelper.cpp b/applets/notifications/plugin/notificationshelper.cpp index b56e3933b..e2880eb23 100644 --- a/applets/notifications/plugin/notificationshelper.cpp +++ b/applets/notifications/plugin/notificationshelper.cpp @@ -263,6 +263,22 @@ void NotificationsHelper::closePopup(const QString &sourceName) bool shouldQueue = popup && !m_hideQueue.contains(popup); m_mutex->unlock(); + // Make sure the notification that was closed (programatically) + // is not in the show queue. This is important otherwise that + // notification will be shown and then never closed (because + // the close event arrives here, before it's even shown) + QMutableListIterator i(m_showQueue); + while (i.hasNext()) { + if (i.next().value("source") == sourceName) { + qDebug() << "########|" << " (locking mutex for write)"; + m_mutex->lockForWrite(); + qDebug() << "########|" << "Removing old data" << i.value().value("summary").toString(); + i.remove(); + m_mutex->unlock(); + qDebug() << "########|" << " (unlocking mutex)"; + } + } + if (shouldQueue) { m_mutex->lockForWrite(); m_hideQueue.append(popup);