Tiny change request for TreeViewItem


#1

Hello!

The current implementation of TreeViewItem::addSubItem () makes a call to getItemHeight() after the parent is assigned, but before the inserting the child into the subItems array. During this time, the new item appears to have a parent assigned, but is not actually a child, so there are some functions which cannot be used safely (e.g. getRowNumberInTree()).

This can be remedied by simply moving the parent assignment to slightly later in the function…

void TreeViewItem::addSubItem (TreeViewItem* const newItem, const int insertPosition)
{
    if (newItem != nullptr)
    {
        newItem->setOwnerView (ownerView);
        newItem->y = 0;
        newItem->itemHeight = newItem->getItemHeight();
        newItem->totalHeight = 0;
        newItem->itemWidth = newItem->getItemWidth();
        newItem->totalWidth = 0;
        newItem->parentItem = this; // moved from before getItemHeight(), so that it does not appear to be a child yet

        ...

Any chance this change could be added?


#2

Gotcha. Sure, no problem, will push that today.