Mick Arundell wrote:
I use many Lists of objects
I have discovered empirically (program failed with EAccessViolation) that
the only method is

procedure Clear; override;

procedure Clear;
var
  Loop : integer
begin
  for Loop := Count - 1 downto 0 do
    TObject(List[Loop]).free;

  inherited Clear;
end;

Using a Loop counting up the first collision occurs when Loop = Count div 2

Perhaps you and Malcolm are on the same wavelength; freeing an object is not the same as calling the list's Delete method.


Freeing an object does *not* remove it from a TList. For that to happen, the object would need to be aware that it was even *in* a TList at all, and objects do not have that knowledge.

Your access violations were caused by something else.

--
Rob

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to