Bug in Treeview with root item invisible

Just starting playing around with JUCE 6, and while updating everything, noticing a graphic change from previous versions… Where changing the rootItem will very briefly flash the items offset by 20 pixels.

TreeViewBug

Regular speed and then slow speed.

After a few hours I determined it’s down to Treeview.cpp TreeView::TreeViewport::handleAsyncUpdate

Specifically const auto startY = owner.rootItemVisible ? 0 : -root->itemHeight the first time called itemHeight hasn’t been calculated yet, so it’s zero… not until updatePositions is called on the next line does itemHeight = getItemHeight() get called…

if (!owner.rootItemVisible && root->itemHeight==0)
				root->itemHeight=root->getItemHeight();

            const auto startY = owner.rootItemVisible ? 0 : -root->itemHeight;
            root->updatePositions (startY);

Seems to take care of things

I’m having trouble reproducing this on Windows and macOS.

Are you doing anything like setting item height dynamically?

I noticed this as well and came to report before finding this thread. But I was going to suggest a slightly simpler change:

How about just change the one line to:
auto startY = owner.rootItemVisible ? 0 : -root->getItemHeight()
?

@oli1: I think the key to repro is to have a TreeViewItem subclass where getItemHeight() is overridden.

EDIT: Looking again, I don’t think the subclass part is necessary. The base class already returns 20 by default for this method.