telepathy-idle: Fix the crash on closing the RoomList channel

Will Thompson wjt at kemper.freedesktop.org
Mon Oct 29 05:39:12 PDT 2012


Module: telepathy-idle
Branch: master
Commit: 5ebe6a7cf1fac6df992cb65ca18cdabf8ece20be
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=5ebe6a7cf1fac6df992cb65ca18cdabf8ece20be

Author: Jonathon Jongsma <jonathon.jongsma at collabora.co.uk>
Date:   Thu Jan 29 11:54:24 2009 -0600

Fix the crash on closing the RoomList channel

The Act of unreffing the Channel emitted the 'closed' signal, and we were
connecting to the closed signal and and unreffing the channel again in the
handler.  It is necessary to unref the channel in response to the 'closed'
signal in order to handle the dbus Close() method, so we store the channel in a
temporary variable and then NULL out the priv->channel variable before unreffing
so that we don't unref again in the closed handler

---

 src/idle-roomlist-channel.c |    8 +-------
 src/idle-roomlist-manager.c |   10 ++++++++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/idle-roomlist-channel.c b/src/idle-roomlist-channel.c
index 781e25b..13d3fe2 100644
--- a/src/idle-roomlist-channel.c
+++ b/src/idle-roomlist-channel.c
@@ -364,17 +364,11 @@ idle_roomlist_channel_close (TpSvcChannel *iface,
                              DBusGMethodInvocation *context)
 {
   IdleRoomlistChannel *obj = IDLE_ROOMLIST_CHANNEL (iface);
-  IdleRoomlistChannelPrivate *priv;
 
   g_assert (obj != NULL);
   g_assert (IDLE_IS_ROOMLIST_CHANNEL (obj));
 
-  priv = IDLE_ROOMLIST_CHANNEL_GET_PRIVATE (obj);
-  priv->closed = TRUE;
-
-  IDLE_DEBUG ("called on %p", obj);
-
-  tp_svc_channel_emit_closed (iface);
+  g_object_run_dispose (G_OBJECT (iface));
 
   tp_svc_channel_return_from_close (context);
 }
diff --git a/src/idle-roomlist-manager.c b/src/idle-roomlist-manager.c
index c2435ab..f8f46f8 100644
--- a/src/idle-roomlist-manager.c
+++ b/src/idle-roomlist-manager.c
@@ -185,11 +185,17 @@ static void
 _roomlist_manager_close_all (IdleRoomlistManager *self)
 {
     IdleRoomlistManagerPrivate *priv = IDLE_ROOMLIST_MANAGER_GET_PRIVATE (self);
+    IdleRoomlistChannel *tmp;
 
-    if (priv->channel)
+    if (priv->channel != NULL)
       {
-        g_object_unref(priv->channel);
+        /* use a temporary variable and set priv->channel to NULL first
+         * because unreffing this channel will cause the
+         * _roomlist_channel_closed_cb to fire, which will try to unref it
+         * again if priv->channel is not NULL */
+        tmp = priv->channel;
         priv->channel = NULL;
+        g_object_unref(tmp);
       }
     if (priv->status_changed_id != 0)
       {



More information about the telepathy-commits mailing list