trichview.com

trichview.support




Re: table and Access violation


Return to index


Author

Message

Sergey Tkachenko

Posted: 07/01/2003 10:42:16


Is TD.Loaded called after TRVTableSW.Destroy? If yes, this is an error.


Object can destroy itself. For example, Free method of each object calls

Destroy destroying this object (of course, after destroying you cannot

access fields and properties of this object). Yes, in this code, TD destroys

TRVTableSW, and TRVTableSW in its case destroys TD. It's absolutely OK.



> it called once for one table but if i understand your code,

> procedure TD.Loaded;

> begin

>   inherited;

>   dec(FCellCount);

>   if FCellCount=0 then

>     FRVTableSW.Free;

> end; // HERE self (the TD object) does not exists because

> TRVTableSW.Destroy destroy it when FCellCount=0 ? in Delphi, an object

> can't destroy itself.

>

> constructor TRVTableSW.Create(AOwner: TComponent);

> begin

>   inherited Create(AOwner);

>   FTD := TD.Create(nil);

>   FTD.FRVTableSW := Self;

> end;

>

> destructor TRVTableSW.Destroy;

> begin

>   FTD.Free;

>   inherited Destroy;

> end;

>

>

> --

> Bruno

>





Powered by ABC Amber Outlook Express Converter