[gnome-contacts] Ensure we don't update the contact after its been removed from the store



commit 5e1b6515def37fefa31f143f74dbbbf42fca1ce5
Author: Alexander Larsson <alexl redhat com>
Date:   Tue May 17 21:04:42 2011 +0200

    Ensure we don't update the contact after its been removed from the store

 src/contacts-contact.vala |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index d5d7c13..6a65334 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -45,7 +45,7 @@ public class Contacts.Contact : GLib.Object  {
   public Individual individual;
   public ContactStore store;
   private TreeIter iter;
-  ulong changed_id;
+  uint changed_id;
 
   private Gdk.Pixbuf? _avatar;
   public Gdk.Pixbuf avatar {
@@ -86,12 +86,12 @@ public class Contacts.Contact : GLib.Object  {
     store.append (out iter);
     store.set (iter, 0, this);
 
-    individual.notify.connect( (pspec) => {
-	queue_changed ();
-      });
+    individual.notify.connect(notify_cb);
   }
 
   public void remove () {
+    unqueue_changed ();
+    individual.notify.disconnect(notify_cb);
     store.remove (this.iter);
   }
 
@@ -111,6 +111,13 @@ public class Contacts.Contact : GLib.Object  {
     return false;
   }
 
+  private void unqueue_changed () {
+    if (changed_id != 0) {
+      Source.remove (changed_id);
+      changed_id = 0;
+    }
+  }
+
   private void queue_changed () {
     if (changed_id != 0)
       return;
@@ -118,6 +125,10 @@ public class Contacts.Contact : GLib.Object  {
     changed_id = Idle.add (changed_cb);
   }
 
+  private void notify_cb (ParamSpec pspec) {
+    queue_changed ();
+  }
+
   private void update () {
     var builder = new StringBuilder ();
     if (individual.alias != null) {



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