Skip to content

OnMeasureItem called before data is assigned to node #756

Closed
@nminkov

Description

tree.AddChild(NULL, userData) will trigger OnMeasureItem() without first "attaching" the data to the node, which is a big issue for VirtualTrees with variable node height. That is, TVirtualNode passed to OnMeasureItem() will not contain the added data while called in AddChild()

Node height is determined by the data contained in the node. Its a "virtual" tree, and its crucial to its concept. This was working properly in the original VirtualTree.

This is caused because of a change in TBaseVirtualTree.SetChildCount.
The original code has even a nice comment:

// The actual node height will later be computed once it is clear
// whether this node has a variable node height or not.
Inc(NewHeight, Child.NodeHeight);

was replaced by

if (toVariableNodeHeight in FOptions.FMiscOptions) then
    GetNodeHeight(Child);
Inc(NewHeight, Child.TotalHeight);

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions