Update ancestor heights on node deletion.

This commit is contained in:
Michael Drake 2013-06-30 22:07:53 +01:00
parent 0c3ac47b05
commit 31450767c9

View File

@ -470,6 +470,7 @@ nserror treeview_delete_node(struct treeview *tree, struct treeview_node *n)
{
struct treeview_node_msg msg;
msg.msg = TREE_MSG_NODE_DELETE;
struct treeview_node *p;
/* Destroy children first */
while (n->children != NULL) {
@ -491,6 +492,13 @@ nserror treeview_delete_node(struct treeview *tree, struct treeview_node *n)
n->sibling_next->sibling_prev = n->sibling_prev;
}
/* Reduce ancestor heights */
p = n->parent;
while (p != NULL && p->flags & TREE_NODE_EXPANDED) {
p->height -= n->height;
p = p->parent;
}
/* Handle any special treatment */
switch (n->type) {
case TREE_NODE_ENTRY: