Mercurial > pidgin.yaz
changeset 15700:074ac986fae0
recursively remove child nodes. This fixes a crash (often caused by going offline)
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Sun, 25 Feb 2007 10:32:34 +0000 |
parents | 1229a0cd9126 |
children | 4a331e8d01df 400252586119 |
files | console/libgnt/gnttree.c |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/console/libgnt/gnttree.c Sun Feb 25 09:07:43 2007 +0000 +++ b/console/libgnt/gnttree.c Sun Feb 25 10:32:34 2007 +0000 @@ -1171,18 +1171,17 @@ void gnt_tree_remove(GntTree *tree, gpointer key) { GntTreeRow *row = g_hash_table_lookup(tree->hash, key); + static int depth = 0; /* Only redraw after all child nodes are removed */ if (row) { gboolean redraw = FALSE; if (row->child) { - GntTreeRow *ch = row->child; - while (ch) { - GntTreeRow *n = ch->next; - tree->list = g_list_remove(tree->list, ch->key); - g_hash_table_remove(tree->hash, ch->key); - ch = n; + depth++; + while (row->child) { + gnt_tree_remove(tree, row->child->key); } + depth--; } if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) >= 0) @@ -1218,11 +1217,11 @@ row->parent->child = row->next; if (row->prev) row->prev->next = row->next; - + g_hash_table_remove(tree->hash, key); tree->list = g_list_remove(tree->list, key); - if (redraw) + if (redraw && depth == 0) { redraw_tree(tree); }