Skip to content

Commit

Permalink
recursivelyCloseSubItems only recurses into open items
Browse files Browse the repository at this point in the history
  • Loading branch information
sudara committed Aug 29, 2023
1 parent 617d282 commit 81cc25a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions melatonin/components/component_tree_view_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,16 @@ namespace melatonin

void recursivelyCloseSubItems()
{
TRACE_COMPONENT("name", getComponentName().toStdString());
TRACE_COMPONENT ("name", getComponentName().toStdString());

for (int i = 0; i < getNumSubItems(); ++i)
{
getSubItem (i)->setOpen (false);
dynamic_cast<ComponentTreeViewItem*> (getSubItem (i))->recursivelyCloseSubItems();
// optimization: only recurse when item is open
if (getSubItem (i)->isOpen())
{
getSubItem (i)->setOpen (false);
dynamic_cast<ComponentTreeViewItem*> (getSubItem (i))->recursivelyCloseSubItems();
}
}
}

Expand Down

0 comments on commit 81cc25a

Please sign in to comment.