Skip to content

Commit 5fa59ba

Browse files
committed
Prevent TBaseVirtualTree.SortTree() from initializing the root nodes.
1 parent f8a9915 commit 5fa59ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Source/VirtualTrees.BaseTree.pas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17202,7 +17202,7 @@ procedure TBaseVirtualTree.EndUpdate;
1720217202
if tsChangePending in FStates then
1720317203
DoChange(FLastChangedNode);
1720417204
finally
17205-
if toAutoSort in FOptions.AutoOptions then
17205+
if (toAutoSort in FOptions.AutoOptions) then
1720617206
SortTree(FHeader.SortColumn, FHeader.SortDirection, True);
1720717207

1720817208
SetUpdateState(False);
@@ -22535,6 +22535,9 @@ procedure TBaseVirtualTree.SortTree(Column: TColumnIndex; Direction: TSortDirect
2253522535
if RootNode.TotalCount <= 2 then
2253622536
Exit;//Nothing to do if there are one or zero nodes. RootNode.TotalCount is 1 if there are no nodes in the treee as the root node counts too here.
2253722537

22538+
if not Assigned(FRoot.FirstChild) then
22539+
Exit; // Sorting should not initialize the root nodes
22540+
2253822541
// Instead of wrapping the sort using BeginUpdate/EndUpdate simply the update counter
2253922542
// is modified. Otherwise the EndUpdate call will recurse here.
2254022543
System.Inc(FUpdateCount);

0 commit comments

Comments
 (0)