[telepathy-glib/master] Assert when assuming connecting to Closed works.

Will Thompson will.thompson at collabora.co.uk
Fri May 15 08:00:46 PDT 2009


---
 telepathy-glib/channel.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c
index 72f333a..82224ed 100644
--- a/telepathy-glib/channel.c
+++ b/telepathy-glib/channel.c
@@ -933,6 +933,8 @@ tp_channel_constructor (GType type,
   GObjectClass *object_class = (GObjectClass *) tp_channel_parent_class;
   TpChannel *self = TP_CHANNEL (object_class->constructor (type,
         n_params, params));
+  GError *error = NULL;
+  TpProxySignalConnection *sc;
 
   /* If our TpConnection dies, so do we. */
   self->priv->conn_invalidated_id = g_signal_connect (self->priv->connection,
@@ -940,10 +942,18 @@ tp_channel_constructor (GType type,
       self);
 
   /* Connect to my own Closed signal and self-destruct when it arrives.
-   * The channel hasn't had a chance to become invalid yet, so we can
-   * assume that this signal connection will work */
-  tp_cli_channel_connect_to_closed (self, tp_channel_closed_cb, NULL, NULL,
-      NULL, NULL);
+   * The channel hasn't had a chance to become invalid yet (it was just
+   * constructed!), so we assert that this signal connection will work */
+  sc = tp_cli_channel_connect_to_closed (self, tp_channel_closed_cb, NULL, NULL,
+      NULL, &error);
+
+  if (sc == NULL)
+    {
+      g_critical ("Couldn't connect to Closed: %s", error->message);
+      g_assert_not_reached ();
+      g_error_free (error);
+      return NULL;
+    }
 
   DEBUG ("%p: constructed with channel type \"%s\", handle #%d of type %d",
       self,
-- 
1.5.6.5




More information about the telepathy-commits mailing list