From 2ddc1bec4c170b5022eb67b7d0451fa4546f8c4a Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 18 Nov 2007 18:25:28 +0000 Subject: #5004 Fix race that caused multiple fake icons appear in the activity frame after installing a bundle with Browse. --- diff --git a/NEWS b/NEWS index d4bfa7d..a248830 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +* #5004 Fix race that caused multiple fake icons appear in the activity frame + after installing a bundle with Browse. (tomeu) + Snapshot 411879e9de * #4768 Fix memory leak when switching between activities. (marco) diff --git a/lib/sugar/activity/registry.py b/lib/sugar/activity/registry.py index a279aa9..c21d4a5 100644 --- a/lib/sugar/activity/registry.py +++ b/lib/sugar/activity/registry.py @@ -130,13 +130,20 @@ class ActivityRegistry(gobject.GObject): return activities def add_bundle(self, bundle_path): - return self._registry.AddBundle(bundle_path) + result = self._registry.AddBundle(bundle_path) + # Need to invalidate here because get_activity could be called after + # add_bundle and before we receive activity-added, causing a race. + self._invalidate_cache() + return result def _activity_added_cb(self, info_dict): - logging.debug('ActivityRegistry._activity_added_cb: flushing caches') + logging.debug('ActivityRegistry._activity_added_cb: invalidating cache') + self._invalidate_cache() + self.emit('activity-added', _activity_info_from_dict(info_dict)) + + def _invalidate_cache(self): self._service_name_to_activity_info.clear() self._mime_type_to_activities.clear() - self.emit('activity-added', _activity_info_from_dict(info_dict)) def remove_bundle(self, bundle_path): return self._registry.RemoveBundle(bundle_path) -- cgit v0.9.1