# HG changeset patch # User Richard Nelson # Date 1172399554 0 # Node ID 074ac986fae09ca87ce033e52063ebec84a60ea8 # Parent 1229a0cd912681109c85b4d200b241cb84822ea6 recursively remove child nodes. This fixes a crash (often caused by going offline) diff -r 1229a0cd9126 -r 074ac986fae0 console/libgnt/gnttree.c --- 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); }