[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
wilder-5.14
Martin Klapetek 11 years ago
parent 08415c47d9
commit e1388789ff
  1. 16
      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<QVariantMap> 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);

Loading…
Cancel
Save