# HG changeset patch # User Nathan Walp # Date 1094001201 0 # Node ID 5d8d73c2eebeb9d2a805a1eb49f4e0a878ad1630 # Parent fb08a0973b3ef6d8a2ade0d8031b08a836b266da [gaim-migrate @ 10820] this shouldn't break anything, and doesn't seem to it might even fix the stupid negative buddy count problem thanks datallah committer: Tailor Script diff -r fb08a0973b3e -r 5d8d73c2eebe src/blist.c --- a/src/blist.c Wed Sep 01 01:07:42 2004 +0000 +++ b/src/blist.c Wed Sep 01 01:13:21 2004 +0000 @@ -965,7 +965,6 @@ GaimBlistUiOps *ops = gaimbuddylist->ui_ops; GaimGroup *g; GaimBlistNode *gnode, *cnode, *bnode; - gboolean empty_contact = FALSE; g_return_if_fail(contact != NULL); g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); @@ -995,19 +994,10 @@ if (cnode->next) cnode->next->prev = cnode->prev; - - if (contact->online > 0) - ((GaimGroup*)cnode->parent)->online--; - if (contact->currentsize > 0) - ((GaimGroup*)cnode->parent)->currentsize--; - ((GaimGroup*)cnode->parent)->totalsize--; - - ops->remove(gaimbuddylist, cnode); - - schedule_blist_save(); - if (cnode->parent != gnode) { - for (bnode = cnode->child; bnode; bnode = bnode->next) { + bnode = cnode->child; + while (bnode) { + GaimBlistNode *next_bnode = bnode->next; GaimBuddy *b = (GaimBuddy*)bnode; struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); @@ -1024,6 +1014,8 @@ if (b->account->gc) serv_move_buddy(b, (GaimGroup *)cnode->parent, g); } else { + gboolean empty_contact = FALSE; + /* this buddy already exists in the group, so we're * gonna delete it instead */ g_free(hb->name); @@ -1034,15 +1026,28 @@ if (!cnode->child->next) empty_contact = TRUE; gaim_blist_remove_buddy(b); + + /** in gaim_blist_remove_buddy(), if the last buddy in a + * contact is removed, the contact is cleaned up and + * g_free'd, so we mustn't try to reference bnode->next */ + if (empty_contact) + return; } + bnode = next_bnode; } } + + if (contact->online > 0) + ((GaimGroup*)cnode->parent)->online--; + if (contact->currentsize > 0) + ((GaimGroup*)cnode->parent)->currentsize--; + ((GaimGroup*)cnode->parent)->totalsize--; + + ops->remove(gaimbuddylist, cnode); + + schedule_blist_save(); } - if (empty_contact) - return; - - if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node))) { if (node->next)