Nur der Vollständigkeit halber ...
So klappts dann auch mit dem rekursiven Free:
Delphi-Quellcode:
procedure FreeLists(List : TObjectList);
var
I : Integer;
Pi : TPI_Root;
SubList : TObjectList;
begin
for I := List.Count - 1 downto 0 do begin
SubList := TPI_Root(List.Items[I]).ITEM_SubItems;
if SubList.Count > 0 then
FreeLists(SubList);
Pi := TPI_Root(List[i]);
List.Delete(I);
if List.OwnsObjects = False then
Pi.Free;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeLists(TestList);
TestList.Free;
end;