[telepathy-glib/master] TpConnectionManager: make dispose() idempotent
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed May 27 02:27:21 PDT 2009
Otherwise, if we get resurrected and re-disposed (as seems to happen
during MC 5 teardown), we try to cancel the name-owner watch twice;
the second time, our TpProxy base class no longer has a TpDBusDaemon,
leading to a null pointer dereference.
---
telepathy-glib/connection-manager.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index ff6da88..6de496c 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -187,6 +187,9 @@ struct _TpConnectionManagerPrivate {
/* TRUE if we're waiting for ListProtocols */
unsigned listing_protocols:1;
+ /* TRUE if dispose() has run already */
+ unsigned disposed:1;
+
/* GPtrArray of TpConnectionManagerProtocol *. This is the implementation
* for self->protocols.
*
@@ -1230,11 +1233,19 @@ tp_connection_manager_init (TpConnectionManager *self)
static void
tp_connection_manager_dispose (GObject *object)
{
- TpProxy *as_proxy = TP_PROXY (object);
+ TpConnectionManager *self = TP_CONNECTION_MANAGER (object);
+ TpProxy *as_proxy = (TpProxy *) self;
+
+ if (self->priv->disposed)
+ goto finally;
+
+ self->priv->disposed = TRUE;
tp_dbus_daemon_cancel_name_owner_watch (as_proxy->dbus_daemon,
- as_proxy->bus_name, tp_connection_manager_name_owner_changed_cb, object);
+ as_proxy->bus_name, tp_connection_manager_name_owner_changed_cb,
+ object);
+finally:
G_OBJECT_CLASS (tp_connection_manager_parent_class)->dispose (object);
}
--
1.5.6.5
More information about the telepathy-commits
mailing list