changeset 19355:5ed02bbcf1ff

Add an assertion in purple_blist_add_{chat,buddy} to return if a buddy was added to the buddy list in a group that is not in the buddy list. This improper usage previously caused duplicate groups to be shown in the buddy list, which are then dropped after restarting Pidgin. This change may incur a performance hit on every buddy added to the buddy list with a non-null group. If this performance is noticeably worse, an alternate assertion (which is less readable) can be used as #2752. Closes #2752.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Fri, 24 Aug 2007 06:11:28 +0000
parents b22a33d3fc95
children 97fcd4429c2f
files libpurple/blist.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/blist.c	Fri Aug 24 04:34:18 2007 +0000
+++ b/libpurple/blist.c	Fri Aug 24 06:11:28 2007 +0000
@@ -1190,6 +1190,9 @@
 			group = purple_group_new(_("Chats"));
 			purple_blist_add_group(group,
 					purple_blist_get_last_sibling(purplebuddylist->root));
+		} else {
+			/* Fail if tried to add buddy to a group that isn't on the blist. #2752. */
+			g_return_if_fail(purple_find_group(group->name));
 		}
 	} else {
 		group = (PurpleGroup*)node->parent;
@@ -1284,6 +1287,10 @@
 		g = (PurpleGroup *)((PurpleBlistNode *)c)->parent;
 	} else {
 		if (group) {
+			/*  Fail if trying to add buddy to a group that is not on the buddy list. 
+			 *  Fix for #2752. */
+			g_return_if_fail(purple_find_group(group->name));
+
 			g = group;
 		} else {
 			g = purple_group_new(_("Buddies"));