LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File bko265206-plasma-notification-crashfix.diff of Package kdebase4-workspace (Project openSUSE:11.4)

diff --git a/plasma/generic/applets/notifications/ui/notificationgroup.cpp b/plasma/generic/applets/notifications/ui/notificationgroup.cpp
index 1f7c0b8..6bbf43c 100644
--- a/plasma/generic/applets/notifications/ui/notificationgroup.cpp
+++ b/plasma/generic/applets/notifications/ui/notificationgroup.cpp
@@ -66,6 +66,8 @@ NotificationGroup::NotificationGroup(Extender *parent, uint groupId)
 
 NotificationGroup::~NotificationGroup()
 {
+    m_extenderItemsForNotification.clear();
+    m_notificationForExtenderItems.clear();
     qDeleteAll(m_notifications);
 }
 
@@ -137,6 +139,11 @@ void NotificationGroup::addNotification(Notification *notification)
 
 void NotificationGroup::extenderItemDestroyed(Plasma::ExtenderItem *object)
 {
+    if (m_extenderItemsForNotification.isEmpty()) {
+        // either we aren't tracking this notification or else we're being deleted
+        return;
+    }
+
     Notification *n = m_notificationForExtenderItems.value(object);
 
     if (n) {
@@ -148,10 +155,16 @@ void NotificationGroup::extenderItemDestroyed(Plasma::ExtenderItem *object)
 
 void NotificationGroup::removeNotification(Notification *notification)
 {
+    if (m_extenderItemsForNotification.isEmpty()) {
+        // either we aren't tracking this notification or else we're being deleted
+        return;
+    }
+
     Plasma::ExtenderItem *item = m_extenderItemsForNotification.value(notification);
     if (item) {
         m_notificationForExtenderItems.remove(item);
     }
+
     m_extenderItemsForNotification.remove(notification);
     m_notifications.removeAll(notification);
     QString applicationName = m_appForNotification.value(notification);
diff --git a/plasma/generic/applets/notifications/ui/notifications.cpp b/plasma/generic/applets/notifications/ui/notifications.cpp
index 9b1a7c0..c7aa6dd 100644
--- a/plasma/generic/applets/notifications/ui/notifications.cpp
+++ b/plasma/generic/applets/notifications/ui/notifications.cpp
@@ -106,6 +106,9 @@ Notifications::~Notifications()
 {
     // stop listening to the manager
     disconnect(m_manager, 0, this, 0);
+    if (m_notificationStackDialog) {
+        disconnect(m_notificationStackDialog, 0, this, 0);
+    }
 
     foreach (Notification *notification, m_manager->notifications()) {
         // we don't want a destroyed managed after the destruction of manager
@@ -342,10 +345,10 @@ void Notifications::initExtenderItem(Plasma::ExtenderItem *extenderItem)
         return;
     }
 
-    if (extenderItem->config().readEntry("type", "") == "job") {
+    if (extenderItem->config().readEntry("type", QString()) == "job") {
         extenderItem->setWidget(new JobWidget(0, extenderItem));
-    //unknown type, this should never happen
     } else {
+        //unknown type, this should never happen
         extenderItem->destroy();
     }
 
diff --git a/plasma/generic/applets/notifications/ui/notificationstack.cpp b/plasma/generic/applets/notifications/ui/notificationstack.cpp
index 2f68961..3b53559 100644
--- a/plasma/generic/applets/notifications/ui/notificationstack.cpp
+++ b/plasma/generic/applets/notifications/ui/notificationstack.cpp
@@ -54,11 +54,9 @@ NotificationStack::~NotificationStack()
 void NotificationStack::addNotification(Notification *notification)
 {
     m_canDismissTimer->start(1000);
-    connect(notification, SIGNAL(notificationDestroyed(Notification *)), this, SLOT(removeNotification(Notification *)));
-    connect(notification, SIGNAL(expired(Notification *)), this, SLOT(delayedRemoveNotification(Notification *)));
-
-    disconnect(notification, SIGNAL(changed(Notification *)), this, SLOT(notificationChanged(Notification *)));
-    connect(notification, SIGNAL(changed(Notification *)), this, SLOT(notificationChanged(Notification *)));
+    connect(notification, SIGNAL(notificationDestroyed(Notification *)), this, SLOT(removeNotification(Notification *)), Qt::UniqueConnection);
+    connect(notification, SIGNAL(expired(Notification *)), this, SLOT(delayedRemoveNotification(Notification *)),  Qt::UniqueConnection);
+    connect(notification, SIGNAL(changed(Notification *)), this, SLOT(notificationChanged(Notification *)), Qt::UniqueConnection);
 
     NotificationWidget *notificationWidget = new NotificationWidget(notification, this);
     notificationWidget->installEventFilter(this);