> From: Rob Kennedy <[EMAIL PROTECTED]>
> Subject: Re: Working with TList objects
> To: Borland's Delphi Discussion List <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> 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
Rob,
You are correct again. My usual Clear routine deletes the list item (so I
don't try to use it again) and Delete frees and then removes the reference
Mick



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

Reply via email to