diff src/list.c @ 5041:c4b691b0cc0d

[gaim-migrate @ 5385] some dragging fixes. hopefully kill off the last of the hangs and crashes associated with dragging buddies and editng the list committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 05 Apr 2003 18:47:34 +0000
parents 070181118a77
children 5b1d70deda02
line wrap: on
line diff
--- a/src/list.c	Sat Apr 05 18:46:37 2003 +0000
+++ b/src/list.c	Sat Apr 05 18:47:34 2003 +0000
@@ -208,7 +208,7 @@
 }
 void  gaim_blist_add_buddy (struct buddy *buddy, struct group *group, GaimBlistNode *node)
 {
-	GaimBlistNode *n = node, *node2, *node3;
+	GaimBlistNode *n = node, *bnode = (GaimBlistNode*)buddy;
 	struct group *g = group;
 	struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
 	gboolean save = FALSE;
@@ -224,28 +224,30 @@
 	}
 
 	/* if we're moving to overtop of ourselves, do nothing */
-	if((GaimBlistNode*)buddy == n)
+	if(bnode == n)
 		return;
 
-	if (((GaimBlistNode*)buddy)->parent) {
+	if (bnode->parent) {
 		/* This buddy was already in the list and is
 		 * being moved.
 		 */
-		ops->remove(gaimbuddylist, (GaimBlistNode*)buddy);
-		node2 = ((GaimBlistNode*)buddy)->next;
-		node3 = ((GaimBlistNode*)buddy)->prev;
+		if(bnode->next)
+			bnode->next->prev = bnode->prev;
+		if(bnode->prev)
+			bnode->prev->next = bnode->next;
+		if(bnode->parent->child == bnode)
+			bnode->parent->child = bnode->next;
 
-		if (node2)
-			node2->prev = node3;
-		if (node3)
-			node3->next = node2;
+		ops->remove(gaimbuddylist, bnode);
 
-		if (((GaimBlistNode*)buddy)->parent != ((GaimBlistNode*)g))
-			serv_move_buddy(buddy, (struct group*)((GaimBlistNode*)buddy)->parent, g);
+		if (bnode->parent != ((GaimBlistNode*)g))
+			serv_move_buddy(buddy, (struct group*)bnode->parent, g);
 		save = TRUE;
 	}
 
 	if (n) {
+		if(n->next)
+			n->next->prev = (GaimBlistNode*)buddy;
 		((GaimBlistNode*)buddy)->next = n->next;
 		((GaimBlistNode*)buddy)->prev = n;
 		((GaimBlistNode*)buddy)->parent = n->parent;