[folks] Copy new URLs for individuals, don't hold stale pointers.



commit a0d19148895f74a3c1d543c3b3e9ff42594e2c5d
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Thu Feb 24 16:42:48 2011 -0800

    Copy new URLs for individuals, don't hold stale pointers.
    
    Fixes bgo#Bug 643241 - _update_urls () needs to create copies of each
    List<FieldDetails>
    
    Code by Raul Gutierrez Segales.

 NEWS                  |    2 ++
 folks/individual.vala |   12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 03527da..117e9d2 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ Overview of changes from libfolks 0.3.6 to libfolks 0.3.7
 
 Bugs fixed:
 * Bug 642351 â?? BACKEND_STORE_KEY_FILE format should support a wildcard entry
+* Bug 643241 â?? _update_urls () needs to create copies of each
+  List<FieldDetails>
 
 Overview of changes from libfolks 0.3.5 to libfolks 0.3.6
 =========================================================
diff --git a/folks/individual.vala b/folks/individual.vala
index 48aaebd..ae9fc47 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -974,6 +974,8 @@ public class Folks.Individual : Object,
        * If the same URL exist multiple times we merge the parameters. */
       var urls_set = new HashTable<unowned string, unowned FieldDetails> (
           str_hash, str_equal);
+      var urls = new GLib.List<FieldDetails> ();
+
       foreach (var persona in this._persona_list)
         {
           var urlable = persona as Urlable;
@@ -985,12 +987,18 @@ public class Folks.Individual : Object,
                   if (existing != null)
                     existing.extend_parameters (ps.parameters);
                   else
-                    urls_set.insert (ps.value, ps);
+                    {
+                      var new_ps = new FieldDetails (ps.value);
+                      new_ps.extend_parameters (ps.parameters);
+                      urls_set.insert (ps.value, new_ps);
+                      urls.prepend ((owned) new_ps);
+                    }
                 }
             }
         }
       /* Set the private member directly to avoid iterating this list again */
-      this._urls = urls_set.get_values ();
+      urls.reverse ();
+      this._urls = (owned) urls;
 
       this.notify_property ("urls");
     }



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