[telepathy-gabble/master] Make SessionHandler.Error() cope with NULL session
Will Thompson
will.thompson at collabora.co.uk
Mon May 11 09:51:40 PDT 2009
The assertion was incorrect: the SessionHandler object might stay alive
on the bus after the session has died, and is secretly on the bus before
the session is born in the first place.
---
src/media-channel.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/media-channel.c b/src/media-channel.c
index 86d1f96..0731f0c 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -2817,12 +2817,25 @@ gabble_media_channel_error (TpSvcMediaSessionHandler *iface,
priv = self->priv;
+ if (priv->session == NULL)
+ {
+ /* This could also be because someone called Error() before the
+ * SessionHandler was announced. But the fact that the SessionHandler is
+ * actually also the Channel, and thus this method is available before
+ * NewSessionHandler is emitted, is an implementation detail. So the
+ * error message describes the only legitimate situation in which this
+ * could arise.
+ */
+ GError e = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "call has already ended" };
+
+ DEBUG ("no session, returning an error.");
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
+
DEBUG ("Media.SessionHandler::Error called, error %u (%s) -- "
"emitting error on each stream", errno, message);
- /* priv->session should be valid throghout SessionHandle D-Bus object life */
- g_assert (priv->session != NULL);
-
g_object_get (priv->session, "state", &state, NULL);
if (state == JS_STATE_ENDED)
--
1.5.6.5
More information about the telepathy-commits
mailing list