Skip to content

Commit da649be

Browse files
committed
Fixed issue #1322: TBaseVirtualTree.IterateSubtree() iterates nothing with StartNode being nil and ChildNodesOnly being True
1 parent 5a20a96 commit da649be

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Source/VirtualTrees.BaseTree.pas

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19851,7 +19851,11 @@ function TBaseVirtualTree.IterateSubtree(StartNode: PVirtualNode; Callback: TVTG
1985119851
Abort := False;
1985219852
Result := StartNode;
1985319853
if Result = nil then
19854-
Stop := nil
19854+
begin
19855+
Stop := nil;
19856+
// Use first node if we start with the root.
19857+
Result := GetFirstNoInit;
19858+
end
1985519859
else
1985619860
begin
1985719861
if not (vsInitialized in Result.States) and DoInit then
@@ -19872,21 +19876,17 @@ function TBaseVirtualTree.IterateSubtree(StartNode: PVirtualNode; Callback: TVTG
1987219876
end;
1987319877
end;
1987419878

19875-
// Use first node if we start with the root.
19876-
if Result = nil then
19877-
Result := GetFirstNoInit;
19878-
1987919879
if Assigned(Result) then
1988019880
begin
1988119881
if not (vsInitialized in Result.States) and DoInit then
1988219882
InitNode(Result);
1988319883

1988419884
// Skip given node if only the child nodes are requested.
19885-
if ChildNodesOnly then
19885+
if ChildNodesOnly and (StartNode <> nil ) then
1988619886
begin
1988719887
if Result.ChildCount = 0 then
1988819888
Result := nil
19889-
else if StartNode <> nil then
19889+
else
1989019890
Result := GetNextNode(Result);
1989119891
end;
1989219892

0 commit comments

Comments
 (0)