]> git.0d.be Git - empathy.git/commitdiff
Move destruction of connections from finalize to dispose.
authorMike Ruprecht <mike.ruprecht@collabora.co.uk>
Wed, 14 Oct 2009 21:59:04 +0000 (16:59 -0500)
committerMike Ruprecht <mike.ruprecht@collabora.co.uk>
Wed, 14 Oct 2009 21:59:04 +0000 (16:59 -0500)
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

index 55f2e75797b48303caac8d0224c5283d919a4cc7..cc0c8198b8fe554e6c9266f462a0c3936c78ff07 100644 (file)
@@ -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);
 }