From 77ea9d56fb15dfd6edb1554ba31c42a7789d62d1 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 9 Aug 2012 14:10:59 +0200 Subject: Use TpWeakRef when user_data of an async call is a widget Keeping a ref on widgets is not enough to keep it alive, because gtk_widget_destroy will run destroy even if there are still refs. https://bugzilla.gnome.org/show_bug.cgi?id=680775 --- libempathy-gtk/empathy-avatar-chooser.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index f75b4fdb9..9f2a5e01c 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -123,15 +123,18 @@ get_avatar_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - TpWeakRef *weak = user_data; - EmpathyAvatarChooser *self = tp_weak_ref_dup_object (weak); + TpWeakRef *wr = user_data; + EmpathyAvatarChooser *self = tp_weak_ref_dup_object (wr); const GArray *avatar; GdkPixbuf *pixbuf; gchar *mime_type; GError *error = NULL; if (self == NULL) - goto out; + { + tp_weak_ref_destroy (wr); + return; + } avatar = tp_account_get_avatar_finish (self->priv->account, result, &error); if (avatar == NULL) @@ -159,10 +162,10 @@ get_avatar_cb (GObject *source, g_free (mime_type); self->priv->changed = FALSE; - g_object_unref (self); out: - tp_weak_ref_destroy (weak); + tp_weak_ref_destroy (wr); + g_object_unref (self); } static void -- cgit v1.2.3