aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-01-24 21:11:01 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-01-24 21:54:18 +0800
commitc06e987f5bccc63f2cf54567850d36f59a51a5f6 (patch)
tree8d33ed8ae3643bc01b3a8bd37fa070f82c1144fe /src
parent760fc904f7b1cb1df34bcee3cfbb57291ccc811c (diff)
downloadgsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.tar
gsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.tar.gz
gsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.tar.bz2
gsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.tar.lz
gsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.tar.xz
gsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.tar.zst
gsoc2013-empathy-c06e987f5bccc63f2cf54567850d36f59a51a5f6.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/empathy-accounts-dialog.c19
1 files 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);