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-31 16:46:45 +0800
commit34aa039f9a2ff39a5912f8dbc012b43e4a99ef40 (patch)
treebec43b5d9e4866cc7122f64d81df310ea00c2fed /src
parentab30e5cff24a01f75cb0f08b138b13504253e2c0 (diff)
downloadgsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.tar
gsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.tar.gz
gsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.tar.bz2
gsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.tar.lz
gsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.tar.xz
gsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.tar.zst
gsoc2013-empathy-34aa039f9a2ff39a5912f8dbc012b43e4a99ef40.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 27026a3c4..ed2dc5c64 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);