I have an array holds data will be represented on TVirtualStringTree. This array is thread-safe and lockable. And grown by another thread.
My problem is that, when VST executes OnMeasureItem event to measure height of the node, data used for measurement can change when it come to the point of printing data with OnGetText event.
I have checked the execution order of events and it is not good for my design. First It fires OnMeasureItem event for all nodes which is not initialized then it starts calling OnGetText events. I mean, suppose we have 3 nodes, events will be fired in that order:
OnMeasureItem for node 1
OnMeasureItem for node 2
OnMeasureItem for node 3
OnGetText for node 1
OnGetText for node 2
OnGetText for node 3
But I need something like this so that I can lock:
OnMeasureItem for node 1
OnGetText for node 1
OnMeasureItem for node 2
OnGetText for node 2
OnMeasureItem for node 3
OnGetText for node 3
What is the best way to maintain synchronization of data obtained between OnMeasureItem and OnGetText events?
I don't want to lock my array during all OnMeasureItem() and OnGetText() events.
Thank you.
Added onTimer:
procedure TMainForm.SyncHexLog;
begin
HexLog.BeginUpdate;
Try
if (HexLog.RootNodeCount <> FirpList.ComOperationCountLagged) then
begin
HexLog.RootNodeCount := FirpList.ComOperationCountLagged;
// measure for fast scrolling
HexLog.ReInitNode(HexLog.GetLastNoInit(), True);
if FAutoScroll then
begin
HexLog.ScrollIntoView(HexLog.GetLast, False, False);
end;
end;
Finally
HexLog.EndUpdate;
End;
end;
toVariableNodeHeight
. Just one additional (maybe irrelevant) question. What version of VirtualTreeView are you using ? – BeaterOnGetText
and try to fake the item height measurement by removingvsHeightMeasured
from node states and callMeasureItemHeight
directly from there. But this will trigger theOnMeasureItem
again, so it's not so good. HoweverMeasureItemHeight
do in fact only two things. It includes thevsHeightMeasured
flag to the node state, trigger theOnMeasureItem
and call privateSetNodeHeight
which set the node's height. – Beater