diff --git a/src/libsnore/notification/notification_p.cpp b/src/libsnore/notification/notification_p.cpp index 2cb594e..d686d68 100644 --- a/src/libsnore/notification/notification_p.cpp +++ b/src/libsnore/notification/notification_p.cpp @@ -41,7 +41,6 @@ NotificationData::NotificationData(const Snore::Application &application, const m_text(text), m_icon(icon), m_priority(priority), - m_closeReason(Notification::NONE), m_hints(m_application.constHints()) { notificationCount++; @@ -58,7 +57,6 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString m_text(text), m_icon(icon), m_priority(priority), - m_closeReason(Notification::NONE), m_hints(m_application.constHints()), m_toReplace(old) { @@ -105,3 +103,13 @@ QString NotificationData::resolveMarkup(const QString &string, Utils::MARKUP_FLA } } +void NotificationData::setBroadcasted() +{ + m_isBroadcasted = true; +} + +bool NotificationData::isBroadcasted() const +{ + return m_isBroadcasted; +} + diff --git a/src/libsnore/notification/notification_p.h b/src/libsnore/notification/notification_p.h index c3e0031..ea4d2eb 100644 --- a/src/libsnore/notification/notification_p.h +++ b/src/libsnore/notification/notification_p.h @@ -50,6 +50,10 @@ public: QString resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags); + void setBroadcasted(); + + bool isBroadcasted() const; + private: Q_DISABLE_COPY(NotificationData) @@ -62,13 +66,14 @@ private: QString m_text; Icon m_icon; Notification::Prioritys m_priority; - Notification::CloseReasons m_closeReason; + Notification::CloseReasons m_closeReason = Notification::NONE; Action m_actionInvoked; QHash m_actions; Hint m_hints; Notification m_toReplace; QScopedPointer m_timeoutTimer; QSet m_activeIn; + bool m_isBroadcasted = false; static uint notificationCount; static uint m_idCount; diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index 9c12b42..c136633 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -113,12 +113,18 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) void SnoreCore::broadcastNotification(Notification notification) { Q_D(SnoreCore); + Q_ASSERT_X(!notification.data()->isBroadcasted(), Q_FUNC_INFO, "Notification was already broadcasted."); + if (notification.data()->isBroadcasted()) { + snoreDebug(SNORE_WARNING) << "Notification" << notification << "was already broadcasted."; + return; + } snoreDebug(SNORE_DEBUG) << "Broadcasting" << notification << "timeout:" << notification.timeout(); if (d->m_notificationBackend != nullptr) { if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) { requestCloseNotification(notification.old(), Notification::REPLACED); } } + notification.data()->setBroadcasted(); emit d->notify(notification); }