From 6f4a8d72f3f97cb13433392431b4bdde9fcc81b0 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Mon, 20 Apr 2015 10:28:07 +0200 Subject: [PATCH] hm we still have a leak with the notifications --- src/libsnore/notification/notification.cpp | 4 ++++ src/libsnore/notification/notification_p.h | 1 + src/libsnore/plugins/plugins.cpp | 6 ++++++ src/libsnore/plugins/plugins.h | 1 + src/libsnore/plugins/snorebackend.cpp | 6 ++---- src/plugins/backends/snarl/snarl.cpp | 4 ++-- src/plugins/backends/snoretoast/snoretoast.cpp | 5 +---- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/libsnore/notification/notification.cpp b/src/libsnore/notification/notification.cpp index a639efc..d622e33 100644 --- a/src/libsnore/notification/notification.cpp +++ b/src/libsnore/notification/notification.cpp @@ -151,6 +151,8 @@ void Notification::addActiveIn(const QObject *o) { d->m_activeIn.insert(o); SnoreCorePrivate::instance()->m_activeNotifications[id()] = *this; + snoreDebug(SNORE_DEBUG) << d->m_activeIn.size() << o << qobject_cast(o); + snoreDebug(SNORE_DEBUG) << SnoreCorePrivate::instance()->m_activeNotifications.size(); } bool Notification::isActiveIn(const QObject *o) const @@ -161,8 +163,10 @@ bool Notification::isActiveIn(const QObject *o) const bool Notification::removeActiveIn(const QObject *o) { bool out = d->m_activeIn.remove(o); + snoreDebug(SNORE_DEBUG) << d->m_activeIn.size() << o << qobject_cast(o); if (d->m_activeIn.isEmpty()) { SnoreCorePrivate::instance()->m_activeNotifications.remove(id()); + snoreDebug(SNORE_DEBUG) << SnoreCorePrivate::instance()->m_activeNotifications.size(); } return out; } diff --git a/src/libsnore/notification/notification_p.h b/src/libsnore/notification/notification_p.h index 9a7068d..0a148d6 100644 --- a/src/libsnore/notification/notification_p.h +++ b/src/libsnore/notification/notification_p.h @@ -75,6 +75,7 @@ private: }; + } #endif // NOTIFICATIONDATA_H diff --git a/src/libsnore/plugins/plugins.cpp b/src/libsnore/plugins/plugins.cpp index 1c4929d..dad7054 100644 --- a/src/libsnore/plugins/plugins.cpp +++ b/src/libsnore/plugins/plugins.cpp @@ -164,6 +164,12 @@ QDebug operator<<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags) } +QDebug operator<<(QDebug debug, const Snore::SnorePlugin *p){ + debug.nospace() << p->metaObject()->className() << "(" << (void*)p << ", " << p->name() << ")"; + return debug.space(); +} + + QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type) { out << static_cast(type); diff --git a/src/libsnore/plugins/plugins.h b/src/libsnore/plugins/plugins.h index f503d1b..b8cf1f5 100644 --- a/src/libsnore/plugins/plugins.h +++ b/src/libsnore/plugins/plugins.h @@ -87,6 +87,7 @@ Q_DECLARE_INTERFACE(Snore::SnorePlugin, "org.Snore.SnorePlugin/1.0") SNORE_EXPORT QDebug operator<<(QDebug, const Snore::SnorePlugin::PluginTypes &); +SNORE_EXPORT QDebug operator<<(QDebug, const Snore::SnorePlugin *); SNORE_EXPORT QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type); SNORE_EXPORT QDataStream &operator>>(QDataStream &in, Snore::SnorePlugin::PluginTypes &type); diff --git a/src/libsnore/plugins/snorebackend.cpp b/src/libsnore/plugins/snorebackend.cpp index 0fac7b5..a6d35f6 100644 --- a/src/libsnore/plugins/snorebackend.cpp +++ b/src/libsnore/plugins/snorebackend.cpp @@ -192,10 +192,8 @@ void SnoreBackend::startTimeout(Notification ¬ification) } timer->setInterval(notification.timeout() * 1000); connect(timer, &QTimer::timeout, [notification](){ - if (notification.isValid()) { - snoreDebug(SNORE_DEBUG) << notification; - SnoreCore::instance().requestCloseNotification(notification, Notification::TIMED_OUT); - } + snoreDebug(SNORE_DEBUG) << notification; + SnoreCore::instance().requestCloseNotification(notification, Notification::TIMED_OUT); }); timer->start(); } diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index 6d97f33..baef3f5 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -30,7 +30,7 @@ #include -#define SNORENOTIFIER_MESSAGE_ID WM_USER + 238 +#define SNORENOTIFIER_MESSAGE_ID WM_USER + 238 using namespace Snore; using namespace Snarl::V42; @@ -255,6 +255,6 @@ void SnarlBackend::slotCloseNotification(Notification notification) return; } ULONG32 id = notification.hints().privateValue(this, "id").toUInt(); - m_idMap.take(id); + m_idMap.remove(id); m_applications.value(notification.application().name())->Hide(id); } diff --git a/src/plugins/backends/snoretoast/snoretoast.cpp b/src/plugins/backends/snoretoast/snoretoast.cpp index 6d93c5c..0042c21 100644 --- a/src/plugins/backends/snoretoast/snoretoast.cpp +++ b/src/plugins/backends/snoretoast/snoretoast.cpp @@ -62,7 +62,7 @@ void SnoreToast::slotNotify(Notification notification) snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements; p->start("SnoreToast", arguements); - p->setProperty("SNORE_NOTIFICATION_ID", notification.id()); + p->setProperty("SNORE_NOTIFICATION", QVariant::fromValue(notification)); } void SnoreToast::slotRegisterApplication(const Application &application) @@ -104,9 +104,6 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus) QProcess *p = qobject_cast(sender()); snoreDebug(SNORE_DEBUG) << p->readAll(); snoreDebug(SNORE_DEBUG) << "Exit code:" << code; - if (p->property("SNORE_NOTIFICATION").isNull()) { - return; - } Notification n = p->property("SNORE_NOTIFICATION").value(); Notification::CloseReasons reason = Notification::NONE;