soc.2009.telepathy: 617f5678: Unref TpContacts when chatroom is invali...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Tue Jul 14 14:01:36 EDT 2009


-----------------------------------------------------------------
Revision: 617f5678c78fb4f714fa6bbe33396d2f7ca977e4
Ancestor: 005c3bc90e11c4f7e5eb114181e165fee10f9a50
Author: sttwister at soc.pidgin.im
Date: 2009-07-14T17:55:47
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/617f5678c78fb4f714fa6bbe33396d2f7ca977e4

Modified files:
        libpurple/protocols/telepathy/telepathy_channel_text.c

ChangeLog: 

Unref TpContacts when chatroom is invalidated

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_text.c	6cb7ca9939eaab24ec3792ed6a88cffddfddf418
+++ libpurple/protocols/telepathy/telepathy_channel_text.c	cc5c6a636c66d4b0fd7cc6e2b582ce1c71bd4f10
@@ -404,15 +404,20 @@ room_channel_invalidated_cb (TpProxy *se
                              gchar   *message,
                              gpointer user_data)
 {
-	telepathy_connection *data = user_data;
+	telepathy_room_channel *data = user_data;
+	telepathy_connection *connection_data = data->connection_data;
 
+	GHashTableIter iter;
+	gpointer key, value;
+
 	/* remove the cached TpChannel proxy when the channel closes */
 	TpHandle handle = tp_channel_get_handle((TpChannel *)self, NULL);
 
 	telepathy_room_channel *tp_channel = NULL;
 	
-	if (data->text_Channels)
-		tp_channel = g_hash_table_lookup(data->room_Channels, (gpointer)handle);
+	if (connection_data->text_Channels)
+		tp_channel = g_hash_table_lookup(connection_data->room_Channels,
+				(gpointer)handle);
 
 	purple_debug_info("telepathy", "Chatroom channel with handle %u closed!\n", handle);
 
@@ -421,6 +426,15 @@ room_channel_invalidated_cb (TpProxy *se
 		tp_channel->channel = NULL;
 	}
 
+	/* Unref all the contacts in the chatroom */
+	g_hash_table_iter_init (&iter, data->contacts);
+	while (g_hash_table_iter_next (&iter, &key, &value)) 
+	{
+		g_object_unref(value);
+	}
+
+	g_hash_table_destroy(data->contacts);
+
 	g_object_unref(self);
 }
 
@@ -471,7 +485,7 @@ handle_room_text_channel (TpChannel *cha
 	}
 
 
-	g_signal_connect(channel, "invalidated", G_CALLBACK(room_channel_invalidated_cb), data);
+	g_signal_connect(channel, "invalidated", G_CALLBACK(room_channel_invalidated_cb), tp_channel);
 
 	tp_cli_channel_type_text_connect_to_send_error(channel,
 			chat_send_error_cb, data, NULL, NULL, &error);


More information about the Commits mailing list