diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-11-03 16:13:28 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-11-03 16:37:57 +0000 |
commit | 4078acb4a2376fd3704d974cd6cfc30cfa4afd1f (patch) | |
tree | 208b160242299e1a75c19db3f20d866113d83757 | |
parent | 5c6c514bc0cc08d831d97bfcbad611c59c5ef89c (diff) | |
download | telepathy-glib-4078acb4a2376fd3704d974cd6cfc30cfa4afd1f.tar.gz |
tp_base_connection_remove_from_bus: factor out from tp_base_connection_dispose
Also call tp_dbus_daemon_unregister_object explicitly, rather than letting
dbus-glib's weak-ref hook do the equivalent a moment later.
-rw-r--r-- | telepathy-glib/base-connection.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index 3e413e7a0..71b111b20 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -405,6 +405,8 @@ struct _TpBaseConnectionPrivate TpDBusDaemon *bus_proxy; /* TRUE after constructor() returns */ gboolean been_constructed; + /* TRUE if on D-Bus */ + gboolean been_registered; /* g_strdup (unique name) => gsize total count * @@ -540,25 +542,9 @@ static void tp_base_connection_interested_name_owner_changed_cb ( gpointer user_data); static void -tp_base_connection_dispose (GObject *object) +tp_base_connection_unregister (TpBaseConnection *self) { - TpBaseConnection *self = TP_BASE_CONNECTION (object); TpBaseConnectionPrivate *priv = self->priv; - guint i; - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - g_assert ((self->status == TP_CONNECTION_STATUS_DISCONNECTED) || - (self->status == TP_INTERNAL_CONNECTION_STATUS_NEW)); - if (self->self_handle != 0) - { - tp_handle_unref (self->priv->handles[TP_HANDLE_TYPE_CONTACT], - self->self_handle); - self->self_handle = 0; - } if (priv->bus_proxy != NULL) { @@ -578,8 +564,37 @@ tp_base_connection_dispose (GObject *object) tp_base_connection_interested_name_owner_changed_cb, self); g_hash_table_iter_remove (&iter); } + + if (priv->been_registered) + tp_dbus_daemon_unregister_object (priv->bus_proxy, self); + + priv->been_registered = FALSE; + } +} + +static void +tp_base_connection_dispose (GObject *object) +{ + TpBaseConnection *self = TP_BASE_CONNECTION (object); + TpBaseConnectionPrivate *priv = self->priv; + guint i; + + if (priv->dispose_has_run) + return; + + priv->dispose_has_run = TRUE; + + g_assert ((self->status == TP_CONNECTION_STATUS_DISCONNECTED) || + (self->status == TP_INTERNAL_CONNECTION_STATUS_NEW)); + if (self->self_handle != 0) + { + tp_handle_unref (self->priv->handles[TP_HANDLE_TYPE_CONTACT], + self->self_handle); + self->self_handle = 0; } + tp_base_connection_unregister (self); + tp_clear_object (&priv->bus_proxy); g_ptr_array_foreach (priv->channel_factories, (GFunc) g_object_unref, NULL); @@ -1753,6 +1768,7 @@ tp_base_connection_register (TpBaseConnection *self, g_return_val_if_fail (TP_IS_BASE_CONNECTION (self), FALSE); g_return_val_if_fail (cm_name != NULL, FALSE); + g_return_val_if_fail (!self->priv->been_registered, FALSE); if (tp_connection_manager_check_valid_protocol_name (priv->protocol, NULL)) { @@ -1831,6 +1847,7 @@ tp_base_connection_register (TpBaseConnection *self, DEBUG ("object path %s", self->object_path); tp_dbus_daemon_register_object (priv->bus_proxy, self->object_path, self); + self->priv->been_registered = TRUE; if (bus_name != NULL) *bus_name = g_strdup (self->bus_name); |