changeset 31712:f7c3aac5b22b

conversation: Use a copy of the name and clear hash after emitting "left" signals
author Paul Aurich <paul@darkrain42.org>
date Tue, 21 Jun 2011 03:34:50 +0000
parents 84ac2406bb10
children 298685661f89
files libpurple/conversation.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/conversation.c	Tue Jun 21 01:58:17 2011 +0000
+++ b/libpurple/conversation.c	Tue Jun 21 03:34:50 2011 +0000
@@ -413,7 +413,7 @@
 		conv->u.chat = g_new0(PurpleConvChat, 1);
 		conv->u.chat->conv = conv;
 		conv->u.chat->users = g_hash_table_new_full(_purple_conversation_user_hash,
-				_purple_conversation_user_equal, NULL, NULL);
+				_purple_conversation_user_equal, g_free, NULL);
 		PURPLE_DBUS_REGISTER_POINTER(conv->u.chat, PurpleConvChat);
 
 		chats = g_list_prepend(chats, conv);
@@ -1702,7 +1702,7 @@
 		cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL;
 
 		chat->in_room = g_list_prepend(chat->in_room, cbuddy);
-		g_hash_table_replace(chat->users, cbuddy->name, cbuddy);
+		g_hash_table_replace(chat->users, g_strdup(cbuddy->name), cbuddy);
 
 		cbuddies = g_list_prepend(cbuddies, cbuddy);
 
@@ -1796,7 +1796,7 @@
 	cb->buddy = purple_find_buddy(conv->account, new_user) != NULL;
 
 	chat->in_room = g_list_prepend(chat->in_room, cb);
-	g_hash_table_replace(chat->users, cb->name, cb);
+	g_hash_table_replace(chat->users, g_strdup(cb->name), cb);
 
 	if (ops != NULL && ops->chat_rename_user != NULL)
 		ops->chat_rename_user(conv, old_user, new_user, new_alias);
@@ -1967,8 +1967,6 @@
 		g_list_free(names);
 	}
 
-	g_hash_table_remove_all(chat->users);
-
 	for (l = users; l; l = l->next)
 	{
 		PurpleConvChatBuddy *cb = l->data;
@@ -1981,6 +1979,9 @@
 		purple_conv_chat_cb_destroy(cb);
 	}
 
+	g_hash_table_remove_all(chat->users);
+	chat->users = NULL;
+
 	g_list_free(users);
 	chat->in_room = NULL;
 }