[empathy/gnome-2-28] Move destruction of connections from finalize to dispose.



commit abfa84d2ad30adfe4f70c707ff179fbdb7a543c5
Author: Mike Ruprecht <mike ruprecht collabora co uk>
Date:   Wed Oct 14 16:59:04 2009 -0500

    Move destruction of connections from finalize to dispose.
    
    Code can potentially be run between the dispose and finalize methods. This
    moves the destruction of connections and subsequently outstanding_requests
    into the dispose function so the request callback can't be fired between
    unreffing the EmpathyDispatcher and cancelling the pending request.

 libempathy/empathy-dispatcher.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 55f2e75..cc0c819 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -944,6 +944,8 @@ static void
 dispatcher_dispose (GObject *object)
 {
   EmpathyDispatcherPriv *priv = GET_PRIV (object);
+  GHashTableIter iter;
+  gpointer connection;
   GList *l;
 
   if (priv->dispose_has_run)
@@ -961,6 +963,16 @@ dispatcher_dispose (GObject *object)
     g_object_unref (priv->handler);
   priv->handler = NULL;
 
+  g_hash_table_iter_init (&iter, priv->connections);
+  while (g_hash_table_iter_next (&iter, &connection, NULL))
+    {
+      g_signal_handlers_disconnect_by_func (connection,
+          dispatcher_connection_invalidated_cb, object);
+    }
+
+  g_hash_table_destroy (priv->connections);
+  priv->connections = NULL;
+
   G_OBJECT_CLASS (empathy_dispatcher_parent_class)->dispose (object);
 }
 
@@ -991,13 +1003,6 @@ dispatcher_finalize (GObject *object)
 
   g_list_free (priv->channels);
 
-  g_hash_table_iter_init (&iter, priv->connections);
-  while (g_hash_table_iter_next (&iter, &connection, NULL))
-    {
-      g_signal_handlers_disconnect_by_func (connection,
-          dispatcher_connection_invalidated_cb, object);
-    }
-
   g_hash_table_iter_init (&iter, priv->outstanding_classes_requests);
   while (g_hash_table_iter_next (&iter, &connection, (gpointer *) &list))
     {
@@ -1007,7 +1012,6 @@ dispatcher_finalize (GObject *object)
 
   g_object_unref (priv->account_manager);
 
-  g_hash_table_destroy (priv->connections);
   g_hash_table_destroy (priv->outstanding_classes_requests);
 }
 



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