[empathy/gnome-2-34] account-dialog: keep a proper weak ref on setting_widget_object
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy/gnome-2-34] account-dialog: keep a proper weak ref on setting_widget_object
- Date: Mon, 31 Jan 2011 08:46:58 +0000 (UTC)
commit 34aa039f9a2ff39a5912f8dbc012b43e4a99ef40
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Mon Jan 24 14:11:01 2011 +0100
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 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 27026a3..ed2dc5c 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -106,12 +106,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;
@@ -485,9 +491,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]