[folks] core: Ensure we always notify of new Individuals



commit 150b7579f1069f561f2069c9efad864b9c87e2e9
Author: Philip Withnall <philip tecnocode co uk>
Date:   Tue Sep 6 21:57:42 2011 +0100

    core: Ensure we always notify of new Individuals
    
    In the following situation, it was possible for
    IndividualAggregator.individuals_changed_detailed to not emit a notification
    that an individual was added:
    
    If two personas were added by a given store in the same emission of
    PersonaStore.personas_changed, the IA would create an Individual, i1, from
    the first and add a mapping (null â i1) to the change set. It would then
    process the second, destroying the first individual and creating a new
    Individual, i2, (correctly) containing both personas. In doing so, it would
    remove the mapping (null â i1) from the change set, but would incorrectly
    not add a mapping (null â i2) in its place.
    
    This situation can be extended to others where a single new Individual is
    formed from multiple new personas coming from a single emission of
    PersonaStore.personas_changed.
    
    Closes: bgo#657282 (again)

 folks/individual-aggregator.vala |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 38c4280..bb8cfd9 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -834,6 +834,8 @@ public class Folks.IndividualAggregator : Object
               this._add_persona_to_link_map (p, final_individual);
             }
 
+          uint num_mappings_added = 0;
+
           foreach (var i in candidate_inds)
             {
               /* Transitively update the individuals_changes. We have to do this
@@ -860,6 +862,7 @@ public class Folks.IndividualAggregator : Object
                   if (k != null)
                     {
                       individuals_changes.set (k, final_individual);
+                      num_mappings_added++;
                     }
                 }
 
@@ -870,12 +873,14 @@ public class Folks.IndividualAggregator : Object
               if (transitive_updates.size == 0)
                 {
                   individuals_changes.set (i, final_individual);
+                  num_mappings_added++;
                 }
             }
 
-          /* If there were no candidate individuals, mark the final_individual
-           * as added. */
-          if (candidate_inds.size == 0)
+          /* If there were no candidate individuals or they were all freshly
+           * added (i.e. mapped from null â candidate_individual), mark the
+           * final_individual as added. */
+          if (num_mappings_added == 0)
             {
               individuals_changes.set (null, final_individual);
             }



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