[telepathy-mission-control/master] McdAccount: emit removed in dispose if it hasn't already been done

Simon McVittie simon.mcvittie at collabora.co.uk
Thu May 14 06:24:29 PDT 2009


This means that if an account is created and momentarily added to the
hash table of accounts, then deleted due to error, it will correctly emit
removed and be removed from the hash table.
---
 src/mcd-account.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/mcd-account.c b/src/mcd-account.c
index 0c266b1..5c37295 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -140,6 +140,7 @@ struct _McdAccountPrivate
     guint loaded : 1;
     guint has_been_online : 1;
     guint temporary_presence : 1;
+    guint removed : 1;
 
     /* These fields are used to cache the changed properties */
     GHashTable *changed_properties;
@@ -1238,12 +1239,13 @@ mcd_account_delete (McdAccount *account, GError **error)
 }
 
 static void
-account_remove (McSvcAccount *self, DBusGMethodInvocation *context)
+account_remove (McSvcAccount *svc, DBusGMethodInvocation *context)
 {
+    McdAccount *self = MCD_ACCOUNT (svc);
     GError *error = NULL;
 
     DEBUG ("called");
-    if (!mcd_account_delete (MCD_ACCOUNT (self), &error))
+    if (!mcd_account_delete (self, &error))
     {
 	if (!error)
 	    g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
@@ -1252,7 +1254,13 @@ account_remove (McSvcAccount *self, DBusGMethodInvocation *context)
 	g_error_free (error);
 	return;
     }
-    mc_svc_account_emit_removed (self);
+
+    if (!self->priv->removed)
+    {
+        self->priv->removed = TRUE;
+        mc_svc_account_emit_removed (self);
+    }
+
     mc_svc_account_return_from_remove (context);
 }
 
@@ -1745,6 +1753,13 @@ _mcd_account_dispose (GObject *object)
     McdAccountPrivate *priv = self->priv;
 
     DEBUG ("%p (%s)", object, priv->unique_name);
+
+    if (!self->priv->removed)
+    {
+        self->priv->removed = TRUE;
+        mc_svc_account_emit_removed (self);
+    }
+
     if (priv->online_requests)
     {
         GError *error;
-- 
1.5.6.5




More information about the telepathy-commits mailing list