[folks/folks-0-4] Disconnect from 'invalidated' on proxies we abandon.



commit 8d1783a28d2d66a771b734a44cb184accb84154e
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Fri Mar 18 12:07:42 2011 -0700

    Disconnect from 'invalidated' on proxies we abandon.
    
    This prevents a crasher in the Telepathy backend where:
    
    1. We hit _reset() and set this._subscribe, etc., to null.
    
    2. Each of these proxies gets disposed and emits 'invalidated'
    
    3. Our 'invalidated' handler ends up unrefing each proxy an extra time, which
    ends up in some ugly dispose -> unref -> dispose recursion, which continues
    after it's finalized, leading to bad/undefined behavior (usually, but not
    always, a crasher).

 NEWS                                          |    1 +
 backends/telepathy/lib/tpf-persona-store.vala |   32 ++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0fafb36..ebc8cba 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Bugs fixed:
   of each List<FieldDetails>
 * Bug 644966 - _update_emails () needs to create copies of each
   List<FieldDetails>
+* Crasher when reconnecting a Telepathy account
 
 Overview of changes from libfolks 0.3.6 to libfolks 0.4.0
 =========================================================
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 1049bb1..c537fdc 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -212,11 +212,37 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       this._group_outgoing_adds = new HashMap<string, HashSet<Tpf.Persona>> ();
       this._group_outgoing_removes = new HashMap<string, HashSet<Tpf.Persona>> (
           );
-      this._publish = null;
-      this._stored = null;
-      this._subscribe = null;
+
+      if (this._publish != null)
+        {
+          this._publish.invalidated.disconnect (this._channel_invalidated_cb);
+          this._publish = null;
+        }
+
+      if (this._stored != null)
+        {
+          this._stored.invalidated.disconnect (this._channel_invalidated_cb);
+          this._stored = null;
+        }
+
+      if (this._subscribe != null)
+        {
+          this._subscribe.invalidated.disconnect (this._channel_invalidated_cb);
+          this._subscribe = null;
+        }
+
       this._standard_channels_unready = new HashMap<string, Channel> ();
       this._group_channels_unready = new HashMap<string, Channel> ();
+
+      if (this._groups != null)
+        {
+          foreach (var channel in this._groups.values)
+            {
+              if (channel != null)
+                channel.invalidated.disconnect (this._channel_invalidated_cb);
+            }
+        }
+
       this._groups = new HashMap<string, Channel> ();
       this._favourite_handles = new HashSet<uint> ();
       this._ll = new TpLowlevel ();



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