[gnome-contacts] Ensure we make a copy of a list that can change over yield calls



commit 538581236be6ef6957c0a1ba289409f7edd56028
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Oct 20 12:31:50 2011 +0200

    Ensure we make a copy of a list that can change over yield calls
    
    This fixes a crash when editing the name of a contact, which apparently
    changed the personas set for the contact.

 src/contacts-contact-pane.vala |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 9c0af09..38fda36 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -365,10 +365,12 @@ public class Contacts.ContactPane : Grid {
 						  Value value) throws GLib.Error, PropertyError {
     selected_contact.is_unedited = false;
     bool did_set = false;
-    foreach (var p in contact.individual.personas) {
+    // Need to make a copy here as it could change during the yields
+    var personas_copy = contact.individual.personas.to_array ();
+    foreach (var p in personas_copy) {
       if (property_name in p.writeable_properties) {
 	did_set = true;
-        yield Contact.set_persona_property (p, property_name, value);
+	yield Contact.set_persona_property (p, property_name, value);
       }
     }
 



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