[folks] individual: Fix linking when personas are moved between individuals weirdly



commit e532982f321ff623a476d6c211eba2895dc14199
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Jul 27 23:43:14 2011 +0100

    individual: Fix linking when personas are moved between individuals weirdly
    
    It's possible (likely, even) for a set of personas to move between two
    individuals during linking. Previously, bad things would happen to
    persona.individual if the personas weren't correctly removed from the first
    individual before being added to the second (e.g. if they were added to the
    second individual before being removed from the first). This fixes that.

 folks/individual.vala |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index ee64d52..bf4897d 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -1258,7 +1258,18 @@ public class Folks.Individual : Object,
               this._persona_group_changed_cb);
         }
 
-      persona.individual = replacement_individual;
+      /* Don't update the individual if the persona's been added to the new one
+       * already (and thus the new individual has already changed
+       * persona.individual).
+       *
+       * FIXME: Ideally, we'd assert that a persona can't be added to a new
+       * individual before it's removed from the old one. However, this
+       * currently isn't possible due to the way the aggregator works. When the
+       * aggregator's rewritten, it would be nice to fix this. */
+      if (persona.individual == this)
+        {
+          persona.individual = replacement_individual;
+        }
     }
 
   private void _update_gender ()
@@ -1504,6 +1515,8 @@ public class Folks.Individual : Object,
   private void _set_personas (Set<Persona>? personas,
       Individual? replacement_individual)
     {
+      assert (replacement_individual == null || replacement_individual != this);
+
       var added = new HashSet<Persona> ();
       var removed = new HashSet<Persona> ();
 



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