V6: Problem in DoMeasureItem

25 views
Skip to first unread message

Christian Kaufmann

unread,
Dec 20, 2014, 4:07:49 PM12/20/14
to virtual-...@googlegroups.com
I switched to the latest version of VirtualTreeView.

In order to have DoMeasureItem called, I have to add toVariableNodeHeight to MiscOptions.

Unfortunately DoMeasureItem is called to early now: It's called before "UserData" of the node is
set, so Node.Data is not valid in DoMeasureItem.

Is this the correct behaviour? Or is it an error in V6?

cu Christian

Joachim Marder

unread,
Dec 22, 2014, 3:18:19 AM12/22/14
to virtual-...@googlegroups.com, chr.ka...@gmail.com
Hi Christian.

Which version were you using previously?
Does the error also occur with the latest official release V5.5.1?
How exactly do you set your user data?

Best regards,

Joachim



--
You received this message because you are subscribed to the Google Groups "Virtual Treeview" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtual-treevi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Kaufmann

unread,
Dec 22, 2014, 5:01:38 AM12/22/14
to virtual-...@googlegroups.com, chr.ka...@gmail.com
I use the latest version from the trunk. I did not try 5.5.1 yet. Under XE2 I was on 5.0.1 and didn't have the problem.

It happens when DoMeasureItem is called in SetChildCount. When I look at AddChild (arround line 27300), this happens before the userdata is assigned to the new nodes Data.

My userdata is simple:

  TBSNodeRecord = packed record
    Data : TBSTreeNode;
  end;

I keep an object for each node and map all Tree methods I need to that objects (virtual) method. I know this is not the original idea of a virtual tree. But I'm using VirtualTreeView because it has so many more features since years.

cu Christian

Joachim Marder

unread,
Dec 22, 2014, 7:07:35 AM12/22/14
to virtual-...@googlegroups.com, chr.ka...@gmail.com
Hi Christian.

So you are supplying your NodeData as optional second parameter of AddChild(), did I get this right?

We can't simply chnage the code order in AddChild() without introducing other issues. A possible solution might be to use a combination of MakeNewNode() and InternalConnectNode() in AddChild(), instead of calling SetChildCount() with +1.

As a quick solution I only see the option to use InsertNode() or to switch to using OnInitNode for userdata initialization.

You sould consider openening an issue for this problem: https://code.google.com/p/virtual-treeview/issues/

Best regards,

Joachim




--

Christian Kaufmann

unread,
Dec 22, 2014, 7:42:08 AM12/22/14
to virtual-...@googlegroups.com, chr.ka...@gmail.com


So you are supplying your NodeData as optional second parameter of AddChild(), did I get this right?
Yes exactly,
 
We can't simply chnage the code order in AddChild() without introducing other issues. A possible solution might be to use a combination of MakeNewNode() and InternalConnectNode() in AddChild(), instead of calling SetChildCount() with +1.
I understand. The problem was introduced with calling DoMeasureItem in SetChildCount(). I'm not sure when/why this happened. In 5.0.1 it's not there. I'm suprised, nobody else had a problem with that, because for measuring the hight individually per node you need the nodes data.

My quick solution was to check for nil of the node data. But then this first call for measuring the item hight is missed. It does not seem a problem for the items, but scrollbars are not adjusted correctly (become visible even though there is no need for one). The funny thing is, as soon as I click the scrollbar and move the caret by some pixels, scrollbars disapear (as expected).

cu Christian
Reply all
Reply to author
Forward
0 new messages