summaryrefslogtreecommitdiff
path: root/telepathy-glib/base-connection-manager.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-12-06 12:34:38 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-12-06 15:59:15 +0000
commit735307470d1aaf2652efca7426182c0446e6ee83 (patch)
tree915b870263cffe459ba3ce4eb691668638ea2438 /telepathy-glib/base-connection-manager.c
parentb47939d5423ca851bca4a2a41d5a1f481a0bfb27 (diff)
downloadtelepathy-glib-735307470d1aaf2652efca7426182c0446e6ee83.tar.gz
TpBaseConnectionManager: ref the CM once per Connection
Some Salut test failures can apparently cause the Connection to outlive the CM, causing a crash when it emits no-more-connections.
Diffstat (limited to 'telepathy-glib/base-connection-manager.c')
-rw-r--r--telepathy-glib/base-connection-manager.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/telepathy-glib/base-connection-manager.c b/telepathy-glib/base-connection-manager.c
index 221e1688b..1c2c30f51 100644
--- a/telepathy-glib/base-connection-manager.c
+++ b/telepathy-glib/base-connection-manager.c
@@ -571,16 +571,24 @@ connection_shutdown_finished_cb (TpBaseConnection *conn,
TpBaseConnectionManager *self = TP_BASE_CONNECTION_MANAGER (data);
TpBaseConnectionManagerPrivate *priv = self->priv;
+ /* temporary ref, because disconnecting this signal handler might release
+ * the last ref */
+ g_object_ref (self);
+
g_assert (g_hash_table_lookup (priv->connections, conn));
g_hash_table_remove (priv->connections, conn);
- g_object_unref (conn);
-
DEBUG ("dereferenced connection");
if (g_hash_table_size (priv->connections) == 0)
{
g_signal_emit (self, signals[NO_MORE_CONNECTIONS], 0);
}
+
+ g_signal_handlers_disconnect_by_func (conn,
+ connection_shutdown_finished_cb, data);
+
+ g_object_unref (conn);
+ g_object_unref (self);
}
/* Parameter parsing */
@@ -990,9 +998,9 @@ tp_base_connection_manager_request_connection (TpSvcConnectionManager *iface,
}
/* bind to status change signals from the connection object */
- g_signal_connect (conn, "shutdown-finished",
- G_CALLBACK (connection_shutdown_finished_cb),
- self);
+ g_signal_connect_data (conn, "shutdown-finished",
+ G_CALLBACK (connection_shutdown_finished_cb),
+ g_object_ref (self), (GClosureNotify) g_object_unref, 0);
/* store the connection, using a hash table as a set */
g_hash_table_insert (priv->connections, conn, GINT_TO_POINTER(TRUE));