gobjectification: 014da2a3: Fixed crash on disconnection.

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sat Jun 2 11:41:22 EDT 2012


----------------------------------------------------------------------
Revision: 014da2a3ef9131e5be38c54fc2e5c872d5fdfe47
Parent:   491ea758f5821699082883635e903827e37d16a3
Author:   gillux at soc.pidgin.im
Date:     06/02/12 10:59:14
Branch:   im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/014da2a3ef9131e5be38c54fc2e5c872d5fdfe47

Changelog: 

Fixed crash on disconnection.
The ipp _purple_connection_destroy() implementation wasn't properly
splitted between GObject's dispose and finalize callbacks.
Emitting a signal from the finalize function results in a crash,
because the object ref count is already zero at that point.

Changes against parent 491ea758f5821699082883635e903827e37d16a3

  patched  libpurple/connection.c

-------------- next part --------------
============================================================
--- libpurple/connection.c	900fbe341034284348ad63ea4f10050ed04066b6
+++ libpurple/connection.c	040c6197d182c6ef55aff7b9d88269408582dd60
@@ -830,6 +830,7 @@ purple_connection_dispose(GObject *obj)
 	GSList *buddies;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	PurpleConnectionPrivate *priv;
+	gboolean remove = FALSE;
 
 	g_return_if_fail(PURPLE_IS_CONNECTION(pc));
 
@@ -839,6 +840,9 @@ purple_connection_dispose(GObject *obj)
 
 	purple_debug_info("connection", "Disconnecting connection %p\n", pc);
 
+	if (purple_connection_get_state(pc) != PURPLE_CONNECTION_STATE_CONNECTING)
+		remove = TRUE;
+
 	g_signal_emit(G_OBJECT(pc), signals[SIG_SIGNING_OFF], 0);
 
 	while (priv->buddy_chats)
@@ -868,22 +872,10 @@ purple_connection_dispose(GObject *obj)
 		buddies = g_slist_delete_link(buddies, buddies);
 	}
 
-	G_OBJECT_CLASS(parent_class)->dispose(obj);
-}
-
-static void
-purple_connection_finalize(GObject *obj)
-{
-	PurpleConnection *pc = PURPLE_CONNECTION(obj);
-	PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(pc);
-	PurpleAccount *account = priv->account;
-	gboolean remove = FALSE;
-
 	connections = g_list_remove(connections, pc);
 
-	if (purple_connection_get_state(pc) != PURPLE_CONNECTION_STATE_CONNECTING)
-		remove = TRUE;
 	purple_connection_set_state(pc, PURPLE_CONNECTION_STATE_DISCONNECTED);
+
 	if (remove)
 		purple_blist_remove_account(account);
 
@@ -893,6 +885,16 @@ purple_connection_finalize(GObject *obj)
 	purple_request_close_with_handle(pc);
 	purple_notify_close_with_handle(pc);
 
+	G_OBJECT_CLASS(parent_class)->dispose(obj);
+}
+
+static void
+purple_connection_finalize(GObject *obj)
+{
+	PurpleConnection *pc = PURPLE_CONNECTION(obj);
+	PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(pc);
+	PurpleAccount *account = priv->account;
+
 	purple_debug_info("connection", "Destroying connection %p\n", pc);
 
 	purple_account_set_connection(account, NULL);


More information about the Commits mailing list