changeset 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 38ecbc8a70bd
children a3469318cf35 adcb44a07a2d
files libpurple/conversation.c pidgin/gtkconv.c
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
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)
 {
--- a/pidgin/gtkconv.c	Wed Jun 27 06:32:56 2007 +0000
+++ b/pidgin/gtkconv.c	Wed Jun 27 09:15:57 2007 +0000
@@ -3684,7 +3684,7 @@
 	if (!strcmp(chat->nick, purple_normalize(conv->account, old_name != NULL ? old_name : name)))
 		is_me = TRUE;
 
-	is_buddy = (purple_find_buddy(conv->account, name) != NULL);
+	is_buddy = cb->buddy;
 
 	tmp = g_utf8_casefold(alias, -1);
 	alias_key = g_utf8_collate_key(tmp, -1);
@@ -5576,7 +5576,7 @@
 
 	g_return_if_fail(new_alias != NULL);
 
-	cbuddy = purple_conv_chat_cb_new(new_name, new_alias, flags);
+	cbuddy = purple_conv_chat_cb_find(chat, new_name);
 
 	add_chat_buddy_common(conv, cbuddy, old_name);
 }