[folks/folks-0-4] Copy new PhoneDetails for individuals, don't hold stale pointers.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks/folks-0-4] Copy new PhoneDetails for individuals, don't hold stale pointers.
- Date: Fri, 18 Mar 2011 20:32:38 +0000 (UTC)
commit a2353b54aa3f1572a87fd951752ef5db3b1ed1fd
Author: Raul Gutierrez Segales <raul gutierrez segales collabora co uk>
Date: Wed Mar 16 22:04:50 2011 +0000
Copy new PhoneDetails for individuals, don't hold stale pointers.
Fixed bgo#644968 - _update_phone_numbers () needs to create copies
of each List<FieldDetails>
NEWS | 2 ++
folks/individual.vala | 13 +++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 51e7c5b..0fafb36 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Overview of changes from libfolks 0.4.0 to libfolks 0.4.1
=========================================================
Bugs fixed:
+* Bug 644968 - _update_phone_numbers() needs to create copies
+ of each List<FieldDetails>
* Bug 644966 - _update_emails () needs to create copies of each
List<FieldDetails>
diff --git a/folks/individual.vala b/folks/individual.vala
index a81036f..fca2136 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -1104,6 +1104,8 @@ public class Folks.Individual : Object,
var phone_numbers_set =
new HashTable<unowned string, unowned FieldDetails> (
str_hash, str_equal);
+ var phones = new GLib.List<FieldDetails> ();
+
foreach (var persona in this._persona_list)
{
var phone_details = persona as PhoneDetails;
@@ -1118,11 +1120,18 @@ public class Folks.Individual : Object,
if (existing != null)
existing.extend_parameters (fd.parameters);
else
- phone_numbers_set.insert (fd.value, fd);
+ {
+ var new_fd = new FieldDetails (fd.value);
+ new_fd.extend_parameters (fd.parameters);
+ phone_numbers_set.insert (fd.value, new_fd);
+ phones.prepend ((owned) new_fd);
+ }
}
}
}
- this._phone_numbers = phone_numbers_set.get_values ();
+ /* Set the private member directly to avoid iterating this list again */
+ phones.reverse ();
+ this._phone_numbers = (owned) phones;
this.notify_property ("phone-numbers");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]