ref buddy before connecting signed off timeout, and unref in the handler soc.2013.gobjectification

Mon, 08 Jul 2013 02:03:29 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 08 Jul 2013 02:03:29 +0530
branch
soc.2013.gobjectification
changeset 34716
fc09ccb6eab5
parent 34715
6cc8de5eda26
child 34717
b3e588adef5a

ref buddy before connecting signed off timeout, and unref in the handler

finch/gntblist.c file | annotate | diff | comparison | revisions
libpurple/blistnodetypes.c file | annotate | diff | comparison | revisions
pidgin/gtkblist.c file | annotate | diff | comparison | revisions
--- a/finch/gntblist.c	Mon Jul 08 00:41:34 2013 +0530
+++ b/finch/gntblist.c	Mon Jul 08 02:03:29 2013 +0530
@@ -2509,6 +2509,7 @@
 			update_node_display(purple_blist_node_get_parent(node), ggblist);
 	}
 
+	g_object_unref(node);
 	return FALSE;
 }
 
@@ -2522,6 +2523,8 @@
 
 	if (fnode->signed_timer)
 		purple_timeout_remove(fnode->signed_timer);
+
+	g_object_ref(node);
 	fnode->signed_timer = purple_timeout_add_seconds(6, (GSourceFunc)buddy_recent_signed_on_off, data);
 	update_node_display(node, ggblist);
 	if (purple_blist_node_get_parent(node) && PURPLE_IS_CONTACT(purple_blist_node_get_parent(node)))
--- a/libpurple/blistnodetypes.c	Mon Jul 08 00:41:34 2013 +0530
+++ b/libpurple/blistnodetypes.c	Mon Jul 08 02:03:29 2013 +0530
@@ -503,13 +503,6 @@
 	g_free(priv->local_alias);
 	g_free(priv->server_alias);
 
-	/* TODO: Now that PurpleBuddy is a GObject, timeout callbacks can
-	 * g_object_ref() it when connecting the callback and
-	 * g_object_unref() it in the handler.  That way, it won't
-	 * get freed while the timeout is pending and this line can
-	 * be removed. */
-	while (g_source_remove_by_user_data((gpointer *)object));
-
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 
--- a/pidgin/gtkblist.c	Mon Jul 08 00:41:34 2013 +0530
+++ b/pidgin/gtkblist.c	Mon Jul 08 02:03:29 2013 +0530
@@ -7697,6 +7697,7 @@
 
 	pidgin_blist_update(NULL, PURPLE_BLIST_NODE(buddy));
 
+	g_object_unref(buddy);
 	return FALSE;
 }
 
@@ -7714,6 +7715,8 @@
 
 	if(gtknode->recent_signonoff_timer > 0)
 		purple_timeout_remove(gtknode->recent_signonoff_timer);
+	
+	g_object_ref(buddy);
 	gtknode->recent_signonoff_timer = purple_timeout_add_seconds(10,
 			(GSourceFunc)buddy_signonoff_timeout_cb, buddy);
 }

mercurial