[folks] Ensure each Persona is added to the relinked_personas list at most once



commit 3b61c964eac1dce60b9ab7d4f6e954fbef70ffa1
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Dec 13 15:35:38 2010 +0000

    Ensure each Persona is added to the relinked_personas list at most once
    
    In some cases when relinking the user's Individual when taking Empathy
    offline, several of the user's Personas can get into the relinked_personas
    list multiple times. This causes an infinite loop of linking and relinking
    those Personas. Closes: bgo#637136

 folks/individual-aggregator.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 1b00f72..2347d50 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -539,6 +539,8 @@ public class Folks.IndividualAggregator : Object
       HashMap<Individual, Individual> replaced_individuals =
           new HashMap<Individual, Individual> ();
       GLib.List<Persona> relinked_personas = null;
+      HashSet<Persona> relinked_personas_set =
+          new HashSet<Persona> (direct_hash, direct_equal);
       HashSet<Persona> removed_personas = new HashSet<Persona> (direct_hash,
           direct_equal);
 
@@ -597,10 +599,12 @@ public class Folks.IndividualAggregator : Object
            * include any of the Personas which have just been removed. */
           foreach (unowned Persona persona in individual.personas)
             {
-              if (removed_personas.contains (persona) == true)
+              if (removed_personas.contains (persona) == true ||
+                  relinked_personas_set.contains (persona) == true)
                 continue;
 
               relinked_personas.prepend (persona);
+              relinked_personas_set.add (persona);
 
               /* Remove links to the Persona */
               this.remove_persona_from_link_map (persona);



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