[folks/folks-0-4] When removing, use a local copy of the personas



commit 0e5438b786d1a46206b64cc6351bbd92fb73a059
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Wed Mar 23 09:33:43 2011 +0000

    When removing, use a local copy of the personas
    
    Removing personas from folks will change our individuals persona list,
    so we need to make a copy to be able to safely iterate it.

 NEWS                             |    1 +
 folks/individual-aggregator.vala |    9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 66ba34e..3d006a7 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Overview of changes from libfolks 0.4.1 to libfolks 0.4.2
 Bugs fixed:
 * Bug 645430 â?? folks-inspect: Use LinkedHashSet to access im-addresses
 * Bug 645411 â?? folks-import segfaults on startup
+* Crasher when removing Personas
 
 Overview of changes from libfolks 0.4.0 to libfolks 0.4.1
 =========================================================
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index f3da07b..6c0bb78 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -794,9 +794,14 @@ public class Folks.IndividualAggregator : Object
   public async void remove_individual (Individual individual) throws GLib.Error
     {
       /* We have to iterate manually since using foreach() requires a sync
-       * lambda function, meaning we can't yield on the remove_persona() call */
+       * lambda function, meaning we can't yield on the remove_persona() call.
+       *
+       * Furthermore, removing personas changes the persona list so we need to
+       * make a copy first */
+      var personas = individual.personas.copy ();
       unowned GLib.List<unowned Persona> i;
-      for (i = individual.personas; i != null; i = i.next)
+
+      for (i = personas; i != null; i = i.next)
         {
           var persona = (Persona) i.data;
           yield persona.store.remove_persona (persona);



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