[Sugar-devel] [PATCH] Don't emit buddy-removed and activity-removed before they have announced #2401

Tomeu Vizoso tomeu.vizoso at collabora.co.uk
Mon Oct 4 13:44:28 EDT 2010


Otherwise we'll get some tracebacks from the listeners of those
signals because they still don't know about those buddies or activities.
---
 src/jarabe/model/neighborhood.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index ed23f7f..478ee46 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -858,7 +858,9 @@ class Neighborhood(gobject.GObject):
 
         buddy = self._buddies[contact_id]
         del self._buddies[contact_id]
-        self.emit('buddy-removed', buddy)
+
+        if buddy.props.key is not None:
+            self.emit('buddy-removed', buddy)
 
     def __activity_added_cb(self, account, room_handle, activity_id):
         logging.debug('__activity_added_cb %r %r', room_handle, activity_id)
@@ -902,7 +904,9 @@ class Neighborhood(gobject.GObject):
             return
         activity = self._activities[activity_id]
         del self._activities[activity_id]
-        self.emit('activity-removed', activity)
+
+        if activity.props.bundle is not None:
+            self.emit('activity-removed', activity)
 
     def __current_activity_updated_cb(self, account, contact_id, activity_id):
         logging.debug('__current_activity_updated_cb %r %r', contact_id,
-- 
1.7.2.3



More information about the Sugar-devel mailing list