From: Philip Withnall Date: Wed, 27 Jul 2011 22:43:14 +0000 (+0100) Subject: individual: Fix linking when personas are moved between individuals weirdly X-Git-Tag: FOLKS_0_6_0~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e532982f321ff623a476d6c211eba2895dc14199;p=platform%2Fupstream%2Ffolks.git 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. --- 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? personas, Individual? replacement_individual) { + assert (replacement_individual == null || replacement_individual != this); + var added = new HashSet (); var removed = new HashSet ();