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 --- .../cc-plugins/empathy-accounts-plugin-widget.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c') diff --git a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c index fe3b6fe5e..f76eb5cd4 100644 --- a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c +++ b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c @@ -291,11 +291,18 @@ manager_prepared_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - EmpathyAccountsPluginWidget *self = user_data; + TpWeakRef *wr = user_data; + EmpathyAccountsPluginWidget *self = tp_weak_ref_dup_object (wr); TpAccountManager *manager = (TpAccountManager *) source; GList *accounts; GError *error = NULL; + if (self == NULL) + { + tp_weak_ref_destroy (wr); + return; + } + if (!tp_proxy_prepare_finish (manager, result, &error)) { g_debug ("Error preparing Account Manager: %s", error->message); @@ -324,6 +331,7 @@ manager_prepared_cb (GObject *source, g_list_free (accounts); out: + tp_weak_ref_destroy (wr); g_object_unref (self); } @@ -354,7 +362,7 @@ empathy_accounts_plugin_widget_constructed (GObject *object) manager = tp_account_manager_dup (); tp_proxy_prepare_async (manager, NULL, - manager_prepared_cb, g_object_ref (self)); + manager_prepared_cb, tp_weak_ref_new (self, NULL, NULL)); g_object_unref (manager); return; } -- cgit v1.2.3