hm we still have a leak with the notifications

This commit is contained in:
Patrick von Reth 2015-04-20 10:28:07 +02:00
parent 0fb7f2d6b2
commit 6f4a8d72f3
7 changed files with 17 additions and 10 deletions

View File

@ -151,6 +151,8 @@ void Notification::addActiveIn(const QObject *o)
{ {
d->m_activeIn.insert(o); d->m_activeIn.insert(o);
SnoreCorePrivate::instance()->m_activeNotifications[id()] = *this; SnoreCorePrivate::instance()->m_activeNotifications[id()] = *this;
snoreDebug(SNORE_DEBUG) << d->m_activeIn.size() << o << qobject_cast<SnorePlugin*>(o);
snoreDebug(SNORE_DEBUG) << SnoreCorePrivate::instance()->m_activeNotifications.size();
} }
bool Notification::isActiveIn(const QObject *o) const 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 Notification::removeActiveIn(const QObject *o)
{ {
bool out = d->m_activeIn.remove(o); bool out = d->m_activeIn.remove(o);
snoreDebug(SNORE_DEBUG) << d->m_activeIn.size() << o << qobject_cast<SnorePlugin*>(o);
if (d->m_activeIn.isEmpty()) { if (d->m_activeIn.isEmpty()) {
SnoreCorePrivate::instance()->m_activeNotifications.remove(id()); SnoreCorePrivate::instance()->m_activeNotifications.remove(id());
snoreDebug(SNORE_DEBUG) << SnoreCorePrivate::instance()->m_activeNotifications.size();
} }
return out; return out;
} }

View File

@ -75,6 +75,7 @@ private:
}; };
} }
#endif // NOTIFICATIONDATA_H #endif // NOTIFICATIONDATA_H

View File

@ -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) QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type)
{ {
out << static_cast<int>(type); out << static_cast<int>(type);

View File

@ -87,6 +87,7 @@ Q_DECLARE_INTERFACE(Snore::SnorePlugin,
"org.Snore.SnorePlugin/1.0") "org.Snore.SnorePlugin/1.0")
SNORE_EXPORT QDebug operator<<(QDebug, const Snore::SnorePlugin::PluginTypes &); 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 &out, const Snore::SnorePlugin::PluginTypes &type);
SNORE_EXPORT QDataStream &operator>>(QDataStream &in, Snore::SnorePlugin::PluginTypes &type); SNORE_EXPORT QDataStream &operator>>(QDataStream &in, Snore::SnorePlugin::PluginTypes &type);

View File

@ -192,10 +192,8 @@ void SnoreBackend::startTimeout(Notification &notification)
} }
timer->setInterval(notification.timeout() * 1000); timer->setInterval(notification.timeout() * 1000);
connect(timer, &QTimer::timeout, [notification](){ connect(timer, &QTimer::timeout, [notification](){
if (notification.isValid()) { snoreDebug(SNORE_DEBUG) << notification;
snoreDebug(SNORE_DEBUG) << notification; SnoreCore::instance().requestCloseNotification(notification, Notification::TIMED_OUT);
SnoreCore::instance().requestCloseNotification(notification, Notification::TIMED_OUT);
}
}); });
timer->start(); timer->start();
} }

View File

@ -30,7 +30,7 @@
#include <iostream> #include <iostream>
#define SNORENOTIFIER_MESSAGE_ID WM_USER + 238 #define SNORENOTIFIER_MESSAGE_ID WM_USER + 238
using namespace Snore; using namespace Snore;
using namespace Snarl::V42; using namespace Snarl::V42;
@ -255,6 +255,6 @@ void SnarlBackend::slotCloseNotification(Notification notification)
return; return;
} }
ULONG32 id = notification.hints().privateValue(this, "id").toUInt(); ULONG32 id = notification.hints().privateValue(this, "id").toUInt();
m_idMap.take(id); m_idMap.remove(id);
m_applications.value(notification.application().name())->Hide(id); m_applications.value(notification.application().name())->Hide(id);
} }

View File

@ -62,7 +62,7 @@ void SnoreToast::slotNotify(Notification notification)
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements; snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
p->start("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) void SnoreToast::slotRegisterApplication(const Application &application)
@ -104,9 +104,6 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
QProcess *p = qobject_cast<QProcess *>(sender()); QProcess *p = qobject_cast<QProcess *>(sender());
snoreDebug(SNORE_DEBUG) << p->readAll(); snoreDebug(SNORE_DEBUG) << p->readAll();
snoreDebug(SNORE_DEBUG) << "Exit code:" << code; snoreDebug(SNORE_DEBUG) << "Exit code:" << code;
if (p->property("SNORE_NOTIFICATION").isNull()) {
return;
}
Notification n = p->property("SNORE_NOTIFICATION").value<Notification>(); Notification n = p->property("SNORE_NOTIFICATION").value<Notification>();
Notification::CloseReasons reason = Notification::NONE; Notification::CloseReasons reason = Notification::NONE;