[next] telepathy-idle: Delay ChannelClosed until after removing channels from data structures

Simon McVittie smcv at kemper.freedesktop.org
Wed May 7 02:18:31 PDT 2014


Module: telepathy-idle
Branch: next
Commit: 4bae965b8d437d570095ff831aaf104f23fc2a2a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=4bae965b8d437d570095ff831aaf104f23fc2a2a

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Apr 22 15:39:56 2014 +0100

Delay ChannelClosed until after removing channels from data structures

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189

---

 src/idle-im-manager.c       |    7 ++++---
 src/idle-muc-manager.c      |   13 ++++++++-----
 src/idle-roomlist-manager.c |    6 +++---
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/idle-im-manager.c b/src/idle-im-manager.c
index 622226c..4f5ed9f 100644
--- a/src/idle-im-manager.c
+++ b/src/idle-im-manager.c
@@ -376,9 +376,6 @@ _im_channel_closed_cb (IdleIMChannel *chan,
 	IdleIMManagerPrivate *priv = IDLE_IM_MANAGER_GET_PRIVATE (self);
 	TpBaseChannel *base = TP_BASE_CHANNEL (chan);
 
-	tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
-													   base);
-
 	if (priv->channels)
 	{
 		TpHandle handle = tp_base_channel_get_target_handle (base);
@@ -387,9 +384,13 @@ _im_channel_closed_cb (IdleIMChannel *chan,
 		{
 			IDLE_DEBUG ("removing channel with handle %u", handle);
 			g_hash_table_remove (priv->channels, GUINT_TO_POINTER (handle));
+			tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
+				base);
 		} else {
 			IDLE_DEBUG ("reopening channel with handle %u due to pending messages",
 				handle);
+			tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
+				base);
 			tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (self),
 				base, NULL);
 		}
diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c
index a6f67ab..52ae67b 100644
--- a/src/idle-muc-manager.c
+++ b/src/idle-muc-manager.c
@@ -689,17 +689,20 @@ static void _channel_closed_cb(IdleMUCChannel *chan, gpointer user_data) {
 
 	g_slist_free(reqs);
 
-	tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (manager),
-		base);
-
 	if (priv->channels) {
 		TpHandle handle = tp_base_channel_get_target_handle (base);
 
-		if (tp_base_channel_is_destroyed (base))
+		if (tp_base_channel_is_destroyed (base)) {
 			g_hash_table_remove(priv->channels, GUINT_TO_POINTER(handle));
-		else
+			tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (manager),
+				base);
+		}
+		else {
+			tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (manager),
+				base);
 			tp_channel_manager_emit_new_channel (TP_CHANNEL_MANAGER (manager), base,
 				NULL);
+		}
 	}
 }
 
diff --git a/src/idle-roomlist-manager.c b/src/idle-roomlist-manager.c
index 47eace1..8070365 100644
--- a/src/idle-roomlist-manager.c
+++ b/src/idle-roomlist-manager.c
@@ -334,15 +334,15 @@ _roomlist_channel_closed_cb (IdleRoomlistChannel *chan,
   IdleRoomlistManager *self = IDLE_ROOMLIST_MANAGER (user_data);
   IdleRoomlistManagerPrivate *priv = self->priv;
 
-  tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
-      TP_BASE_CHANNEL (chan));
-
   if (priv->channel)
     {
       g_assert (priv->channel == chan);
       g_object_unref (priv->channel);
       priv->channel = NULL;
     }
+
+  tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
+      TP_BASE_CHANNEL (chan));
 }
 
 



More information about the telepathy-commits mailing list