From c06e987f5bccc63f2cf54567850d36f59a51a5f6 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 24 Jan 2011 14:11:01 +0100 Subject: account-dialog: keep a proper weak ref on setting_widget_object This prevent us of trying to use it after it has been disposed. For example, when switching to an Haze account, we have to wait that the EmpathyAccountSettings is ready before getting the new setting_widget_object but we can't try using the old one while waiting (#640411). --- src/empathy-accounts-dialog.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index f1a21140b..919ba3f03 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -105,12 +105,18 @@ typedef struct { GtkWidget *spinner; gboolean loading; - /* We have to keep a reference on the actual EmpathyAccountWidget, not just - * his GtkWidget. It is the only reliable source we can query to know if + /* We have to keep a weak reference on the actual EmpathyAccountWidget, not + * just its GtkWidget. It is the only reliable source we can query to know if * there are any unsaved changes to the currently selected account. We can't * look at the account settings because it does not contain everything that * can be changed using the EmpathyAccountWidget. For instance, it does not - * contain the state of the "Enabled" checkbox. */ + * contain the state of the "Enabled" checkbox. + * + * Even if we create it ourself, we just get a weak ref and not a strong one + * as EmpathyAccountWidget unrefs itself when the GtkWidget is destroyed. + * That's kinda ugly; cf bgo #640417. + * + * */ EmpathyAccountWidget *setting_widget_object; gboolean connecting_show; @@ -484,9 +490,16 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, const gchar *icon_name; TpAccount *account; + if (priv->setting_widget_object != NULL) + g_object_remove_weak_pointer (G_OBJECT (priv->setting_widget_object), + (gpointer *) &priv->setting_widget_object); + priv->setting_widget_object = empathy_account_widget_new_for_protocol (settings, FALSE); + g_object_add_weak_pointer (G_OBJECT (priv->setting_widget_object), + (gpointer *) &priv->setting_widget_object); + if (accounts_dialog_has_valid_accounts (dialog)) empathy_account_widget_set_other_accounts_exist ( priv->setting_widget_object, TRUE); -- cgit v1.2.3