From 224443c1843ab0df7ef8ee1eda0409c35a4745a9 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 9 Jun 2014 15:39:23 +0200 Subject: mcd-account: unregister the account once we're done deleting it The McdAccount object may still be alive for a short while because of pending async operations. We want to get rid of the D-Bus object as soon as possible and so, for example, a new Account object replacing the deleted one can be created. Fix https://bugs.freedesktop.org/show_bug.cgi?id=79827 --- src/mcd-account.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mcd-account.c b/src/mcd-account.c index f9e874ee..48880bef 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -126,6 +126,7 @@ struct _McdAccountPrivate McdStorage *storage; TpDBusDaemon *dbus_daemon; + gboolean registered; McdConnectivityMonitor *connectivity; McdAccountConnectionContext *connection_context; @@ -686,6 +687,22 @@ account_delete_identify_account_cb (TpProxy *protocol, g_object_unref (account); } +static void +unregister_dbus_service (McdAccount *self) +{ + DBusGConnection *dbus_connection; + + g_return_if_fail (MCD_IS_ACCOUNT (self)); + + if (!self->priv->registered) + return; + + dbus_connection = tp_proxy_get_dbus_connection (self->priv->dbus_daemon); + dbus_g_connection_unregister_g_object (dbus_connection, (GObject *) self); + + self->priv->registered = FALSE; +} + void mcd_account_delete (McdAccount *account, McdAccountDeleteCb callback, @@ -769,6 +786,8 @@ mcd_account_delete (McdAccount *account, priv->removed = TRUE; tp_svc_account_emit_removed (account); } + + unregister_dbus_service (account); } void @@ -3067,10 +3086,13 @@ register_dbus_service (McdAccount *self, dbus_connection = tp_proxy_get_dbus_connection (TP_PROXY (dbus_daemon)); - if (G_LIKELY (dbus_connection)) - dbus_g_connection_register_g_object (dbus_connection, - self->priv->object_path, - (GObject *) self); + if (G_LIKELY (dbus_connection)) { + dbus_g_connection_register_g_object (dbus_connection, + self->priv->object_path, + (GObject *) self); + + self->priv->registered = TRUE; + } } /* -- cgit v1.2.3