diff --git a/NEWS b/NEWS index d4bfa7d2..a248830d 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 a279aa9c..c21d4a50 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)