eds: handle removal of store without removal of personas
authorPatrick Ohly <patrick.ohly@intel.com>
Wed, 5 Dec 2012 14:57:21 +0000 (15:57 +0100)
committerPatrick Ohly <patrick.ohly@intel.com>
Fri, 7 Dec 2012 17:29:44 +0000 (18:29 +0100)
The assumption in the IndividualAggregator that all backends remove
their personas before removing a store did not hold for the EDS
backend when stores were removed via set_persona_stores() or
disable_store().

Fixing that in EDS is tricky, so better make the IndividualAggregator
more resilient and remove any remaining personas when the store gets
removed.

Closes: https://bugzilla.gnome.org/show_bug.cgi?id=689146

NEWS
folks/individual-aggregator.vala

diff --git a/NEWS b/NEWS
index e12228b..540d396 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@ Bugs fixed:
   functions
 • Bug 688834 — getting properties creates data structures over and over again
 • Bug 688923 — remove URLs (blog, free/busy, video, home page)
+• Bug 689146 — disabling EDS address books does not remove personas
 
 API changes:
 • Add Backend.enable_persona_store and disable_persona_store.
index 13e052c..18865f1 100644 (file)
@@ -904,9 +904,24 @@ public class Folks.IndividualAggregator : Object
           this._notify_if_is_quiescent ();
         }
 
-      /* no need to remove this store's personas from all the individuals, since
-       * they'll do that themselves (and emit their own 'removed' signal if
-       * necessary) */
+      /* Not all stores emit a 'removed' signal under all circumstances.
+       * The EDS backend doesn't do it when set_persona_stores() or disable_store()
+       * are used to disable a store.
+       * Therefore remove this store's personas from all the individuals. Should
+       * not have any effect if a store already triggered the 'removed' signals,
+       * because then we won't have anything here.
+       * See https://bugzilla.gnome.org/show_bug.cgi?id=689146
+       */
+
+      var removed_personas = new HashSet<Persona> ();
+      var iter = store.personas.map_iterator ();
+
+      while (iter.next () == true)
+        {
+          removed_personas.add (iter.get_value ());
+        }
+      this._personas_changed_cb (store, new HashSet<Persona> (), removed_personas,
+          null, null, GroupDetails.ChangeReason.NONE);
 
       if (this._primary_store == store)
         {