[folks] Combine personas_changed() emissions for Individuals replaced due to relinking



commit 682c84da19a88cf64174a4c9d39c24f48ccefce9
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Sun Oct 31 16:26:51 2010 +0000

    Combine personas_changed() emissions for Individuals replaced due to relinking
    
    This re-fixes bgo#632564 so that the optimisation of grouping emissions of
    the personas_changed() signal is preserved. Closes: bgo#632564

 folks/individual-aggregator.vala |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 20106cf..58e7540 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -612,6 +612,18 @@ public class Folks.IndividualAggregator : Object
       this.add_personas (relinked_personas, ref added_individuals,
           ref replaced_individuals, ref user);
 
+      /* Signal the removal of the replaced_individuals at the same time as the
+       * removed_individuals. (The only difference between replaced individuals
+       * and removed ones is that replaced individuals specify a replacement
+       * when they emit their Individual:removed signal. */
+      if (replaced_individuals != null)
+        {
+          MapIterator<Individual, Individual> iter =
+              replaced_individuals.map_iterator ();
+          while (iter.next () == true)
+            removed_individuals.prepend (iter.get_key ());
+        }
+
       /* Notify of changes to this.user */
       this.user = user;
 
@@ -655,6 +667,11 @@ public class Folks.IndividualAggregator : Object
 
   private void individual_removed_cb (Individual i, Individual? replacement)
     {
+      /* Only signal if the individual is still in this.individuals. This allows
+       * us to group removals together in, e.g., personas_changed_cb(). */
+      if (this.individuals.lookup (i.id) == null)
+        return;
+
       if (this.user == i)
         this.user = null;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]