summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-11 01:10:25 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-11 01:10:25 +0200
commitf0564ad9d210cc68bfb1bfc6e56b86fa941ad830 (patch)
tree0401716e7af8be4318be1b9e88eca1cc8ad28d39 /libsowatch
parent1b8f2a0e2e63b1f881b6ba7b18982353b9c27b19 (diff)
downloadsowatch-f0564ad9d210cc68bfb1bfc6e56b86fa941ad830.tar.gz
sowatch-f0564ad9d210cc68bfb1bfc6e56b86fa941ad830.zip
more fixes
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/watchserver.cpp40
-rw-r--r--libsowatch/watchserver.h1
2 files changed, 41 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);
+ }
+ }
}
}
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index c1e6ef0..edb4e1a 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -104,6 +104,7 @@ private slots:
void handleNotificationChanged();
void handleNotificationDismissed();
+ void handleNotificationDestroyed();
};
}