diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-08-11 01:10:25 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-08-11 01:10:25 +0200 |
commit | f0564ad9d210cc68bfb1bfc6e56b86fa941ad830 (patch) | |
tree | 0401716e7af8be4318be1b9e88eca1cc8ad28d39 /libsowatch/watchserver.cpp | |
parent | 1b8f2a0e2e63b1f881b6ba7b18982353b9c27b19 (diff) | |
download | sowatch-f0564ad9d210cc68bfb1bfc6e56b86fa941ad830.tar.gz sowatch-f0564ad9d210cc68bfb1bfc6e56b86fa941ad830.zip |
more fixes
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r-- | libsowatch/watchserver.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 2cadc98..35d2429 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -245,6 +245,7 @@ void WatchServer::postNotification(Notification *notification) connect(notification, SIGNAL(changed()), SLOT(handleNotificationChanged())); connect(notification, SIGNAL(dismissed()), SLOT(handleNotificationDismissed())); + connect(notification, SIGNAL(destroyed()), SLOT(handleNotificationDestroyed())); qDebug() << "notification received" << notification->title() << "(" << notification->count() << ")"; @@ -360,5 +361,44 @@ void WatchServer::handleNotificationDismissed() _weather = 0; } } + + // No longer interested in this notification + disconnect(n, 0, this, 0); + } +} + +void WatchServer::handleNotificationDestroyed() +{ + QObject *obj = sender(); + if (obj) { + Notification* n = static_cast<Notification*>(obj); + // Cannot call any methods of n; it is a dangling pointer now. + if (_notificationCounts.contains(n)) { + qWarning() << "Notification destroyed without being dismissed!"; + _notificationCounts.remove(n); + + for (int i = 0; i < Notification::TypeCount; i++) { + Notification::Type type = static_cast<Notification::Type>(i); + if (_notifications[type].contains(n)) { + _notifications[type].removeAll(n); + _watch->updateNotificationCount(type, getNotificationCount(type)); + + if (type == Notification::WeatherNotification) { + WeatherNotification* w = static_cast<WeatherNotification*>(n); + if (_weather == w) { + _weather = 0; + } + } + } + } + + if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) { + qDebug() << "removing top notification"; + _pendingNotifications.removeAll(n); + nextNotification(); + } else { + _pendingNotifications.removeAll(n); + } + } } } |