/soc/2013/ankitkv/gobjectification: fc09ccb6eab5: ref buddy befo...
Ankit Vani
a at nevitus.org
Sun Jul 7 16:33:41 EDT 2013
Changeset: fc09ccb6eab5e1fc31ac8b0f499fbbaedce3efa1
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-08 02:03 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/fc09ccb6eab5
Description:
ref buddy before connecting signed off timeout, and unref in the handler
diffstat:
finch/gntblist.c | 3 +++
libpurple/blistnodetypes.c | 7 -------
pidgin/gtkblist.c | 3 +++
3 files changed, 6 insertions(+), 7 deletions(-)
diffs (57 lines):
diff --git a/finch/gntblist.c b/finch/gntblist.c
--- a/finch/gntblist.c
+++ b/finch/gntblist.c
@@ -2509,6 +2509,7 @@ buddy_recent_signed_on_off(gpointer data
update_node_display(purple_blist_node_get_parent(node), ggblist);
}
+ g_object_unref(node);
return FALSE;
}
@@ -2522,6 +2523,8 @@ buddy_signed_on_off_cb(gpointer data)
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)))
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -503,13 +503,6 @@ purple_buddy_finalize(GObject *object)
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);
}
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -7697,6 +7697,7 @@ static gboolean buddy_signonoff_timeout_
pidgin_blist_update(NULL, PURPLE_BLIST_NODE(buddy));
+ g_object_unref(buddy);
return FALSE;
}
@@ -7714,6 +7715,8 @@ static void buddy_signonoff_cb(PurpleBud
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);
}
More information about the Commits
mailing list