pidgin.next.minor: f4d5c0f5: conversation: Use a copy of the name and...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue Jun 21 00:52:45 EDT 2011


----------------------------------------------------------------------
Revision: f4d5c0f55ddcacbb71b8fb16642cb0fd7344903f
Parent:   55e35d59034833a953d81bed06b4811fb3724f12
Author:   darkrain42 at pidgin.im
Date:     06/20/11 23:34:50
Branch:   im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/f4d5c0f55ddcacbb71b8fb16642cb0fd7344903f

Changelog: 

conversation: Use a copy of the name and clear hash after emitting "left" signals

Changes against parent 55e35d59034833a953d81bed06b4811fb3724f12

  patched  libpurple/conversation.c

-------------- next part --------------
============================================================
--- libpurple/conversation.c	a13c8d8cbb7916b7ff5a0236ccac696746bb4ce3
+++ libpurple/conversation.c	42560dbf96f8031925d95450e459ed38246a98b1
@@ -413,7 +413,7 @@ purple_conversation_new(PurpleConversati
 		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 @@ purple_conv_chat_add_users(PurpleConvCha
 		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 @@ purple_conv_chat_rename_user(PurpleConvC
 	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 @@ purple_conv_chat_clear_users(PurpleConvC
 		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_clear_users(PurpleConvC
 		purple_conv_chat_cb_destroy(cb);
 	}
 
+	g_hash_table_remove_all(chat->users);
+	chat->users = NULL;
+
 	g_list_free(users);
 	chat->in_room = NULL;
 }


More information about the Commits mailing list