[telepathy-mission-control/master] McdConnection: if we're given a new TpConnection, release the old one rather than leaking it
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Jun 3 09:21:16 PDT 2009
---
src/mcd-connection.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 2d7bed2..b576daa 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -2133,8 +2133,26 @@ _mcd_connection_set_tp_connection (McdConnection *connection,
g_return_if_fail (MCD_IS_CONNECTION (connection));
priv = connection->priv;
+
+ if (priv->tp_conn != NULL)
+ {
+ if (G_UNLIKELY (!tp_strdiff (tp_proxy_get_object_path (priv->tp_conn),
+ obj_path)))
+ {
+ /* not really meant to happen */
+ g_warning ("%s: We already have %s", G_STRFUNC,
+ tp_proxy_get_object_path (priv->tp_conn));
+ return;
+ }
+
+ DEBUG ("releasing old connection first");
+ _mcd_connection_release_tp_connection (connection);
+ }
+
+ g_assert (priv->tp_conn == NULL);
priv->tp_conn = tp_connection_new (priv->dbus_daemon, bus_name,
obj_path, error);
+ DEBUG ("new connection is %p", priv->tp_conn);
if (!priv->tp_conn)
{
g_signal_emit (connection, signals[CONNECTION_STATUS_CHANGED], 0,
--
1.5.6.5
More information about the telepathy-commits
mailing list