[lazarus] Order of destruction in TCustomListBox

Marc Weustink marc at dommelstein.net
Sat Dec 13 11:57:12 EST 2003


At 18:08 13-12-2003, Stoian Ivanov wrote:
>  Hi all,
>
>I'm monitoring this list from some time and this is the first time i notice
>a possible error condition:
>
> > > destructor TCustomListBox.Destroy;
> > > begin
> > >   FreeAndNil(FCanvas);
> > >   inherited Destroy;
> > >   FreeAndNil(FItems);
> > > end;
>
>On heavy load the sytem can map-out the page containing the object's data
>once it is freed via inherited Destroy thus invalidating the
>refference to FItems (assuming it is a field mamber) the solution to the
>problem (if destruction odret is to be kept) should be:

I don't sure know for FPC (I asume it is), but this isn't the case for 
Delphi. The memory object is freed after destroy is called. Your statement 
is valid for good old TMyObj=object(TObject) but not for classes. So where 
inherited destroy is callled, the reference to FItems is valid intil you 
freed them yourself.

Marc.


>destructor TCustomListBox.Destroy;
>var
>     stack_FItems:Txxxxxxx
>begin
>     stack_FItems:=FItems;
>    FreeAndNil(FCanvas);
>    inherited Destroy;
>//  FItems:=nill;
>   stack_FItems.Free;
>end;
>
>_________________________________________________________________
>      To unsubscribe: mail lazarus-request at miraclec.com with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives






More information about the Lazarus mailing list