diff libpurple/conversation.c @ 18305:ffd706ec0220

Set and use convchatbuddy->buddy. This change also makes sure we don't leak everytime any user in a chatroom changes nick. Thanks to stingray for noticing this. Fixes #1818.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 27 Jun 2007 09:15:57 +0000
parents 9b9e202eb449
children f4d05584369e
line wrap: on
line diff
--- a/libpurple/conversation.c	Wed Jun 27 06:32:56 2007 +0000
+++ b/libpurple/conversation.c	Wed Jun 27 09:15:57 2007 +0000
@@ -1563,6 +1563,7 @@
 				purple_conv_chat_is_user_ignored(chat, user);
 
 		cbuddy = purple_conv_chat_cb_new(user, alias, flag);
+		cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL;
 		/* This seems dumb. Why should we set users thousands of times? */
 		purple_conv_chat_set_users(chat,
 				g_list_prepend(chat->in_room, cbuddy));
@@ -1631,11 +1632,6 @@
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
 	g_return_if_fail(prpl_info != NULL);
 
-	flags = purple_conv_chat_user_get_flags(chat, old_user);
-	cb = purple_conv_chat_cb_new(new_user, NULL, flags);
-	purple_conv_chat_set_users(chat,
-		g_list_prepend(chat->in_room, cb));
-
 	if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) {
 		const char *alias;
 
@@ -1659,6 +1655,12 @@
 			new_alias = purple_buddy_get_contact_alias(buddy);
 	}
 
+	flags = purple_conv_chat_user_get_flags(chat, old_user);
+	cb = purple_conv_chat_cb_new(new_user, new_alias, flags);
+	cb->buddy = purple_find_buddy(conv->account, new_user) != NULL;
+	purple_conv_chat_set_users(chat,
+		g_list_prepend(chat->in_room, cb));
+
 	if (ops != NULL && ops->chat_rename_user != NULL)
 		ops->chat_rename_user(conv, old_user, new_user, new_alias);
 
@@ -1949,6 +1951,7 @@
 
 	return chat->left;
 }
+
 PurpleConvChatBuddy *
 purple_conv_chat_cb_new(const char *name, const char *alias, PurpleConvChatBuddyFlags flags)
 {