[folks/folks-0-4] Tidy up signal disconnections in IndividualAggregator



commit baab490aa6015780e0c655c282fa069a6e87bb9f
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Fri Apr 22 22:47:49 2011 +0100

    Tidy up signal disconnections in IndividualAggregator
    
    Closes: bgo#645186

 NEWS                             |    6 ++++++
 folks/individual-aggregator.vala |   27 +++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 7b2c866..afb3230 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Overview of changes from libfolks 0.4.3 to libfolks 0.4.4
+=========================================================
+
+Bugs fixed:
+* Bug 645186 â?? Make sure all connect() calls have appropriate disconnect() calls
+
 Overview of changes from libfolks 0.4.2 to libfolks 0.4.3
 =========================================================
 
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 3d91fe1..1aec5b0 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -153,6 +153,13 @@ public class Folks.IndividualAggregator : Object
           this._backend_available_cb);
     }
 
+  ~IndividualAggregator ()
+    {
+      this._backend_store.backend_available.disconnect (
+          this._backend_available_cb);
+      this._backend_store = null;
+    }
+
   /**
    * Prepare the IndividualAggregator for use.
    *
@@ -265,6 +272,18 @@ public class Folks.IndividualAggregator : Object
       return type_id + ":" + id;
     }
 
+  private void _connect_to_individual (Individual individual)
+    {
+      individual.removed.connect (this._individual_removed_cb);
+      this.individuals.insert (individual.id, individual);
+    }
+
+  private void _disconnect_from_individual (Individual individual)
+    {
+      this.individuals.remove (individual.id);
+      individual.removed.disconnect (this._individual_removed_cb);
+    }
+
   private void _add_personas (GLib.List<Persona> added,
       ref GLib.List<Individual> added_individuals,
       ref HashMap<Individual, Individual> replaced_individuals,
@@ -485,9 +504,8 @@ public class Folks.IndividualAggregator : Object
       foreach (var i in almost_added_individuals)
         {
           /* Add the new Individual to the aggregator */
-          i.removed.connect (this._individual_removed_cb);
           added_individuals.prepend (i);
-          this.individuals.insert (i.id, i);
+          this._connect_to_individual (i);
         }
     }
 
@@ -608,7 +626,7 @@ public class Folks.IndividualAggregator : Object
           if (user == individual)
             user = null;
 
-          this.individuals.remove (individual.id);
+          this._disconnect_from_individual (individual);
           individual.personas = null;
         }
 
@@ -700,7 +718,8 @@ public class Folks.IndividualAggregator : Object
       /* If the individual has 0 personas, we've already signaled removal */
       if (i.personas.length () > 0)
         this.individuals_changed (null, i_list, null, null, 0);
-      this.individuals.remove (i.id);
+
+      this._disconnect_from_individual (i);
     }
 
   /**



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