[fpc-devel] TCustomApplication's parent class?

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Apr 26 11:42:20 CEST 2008


On Sat, 26 Apr 2008 10:52:49 +0200
Vincent Snijders <vsnijders at quicknet.nl> wrote:

> Graeme Geldenhuys schreef:
> > Hi,
> > 
> > Why does TCustomApplication derive from TComponent instead of
> > TObject? What is the reason behind this? Is there any benefits
> > unknown to me? Surely we never need to persist the Appplication
> > class. And it it's because we wanted RTTI support, again we could
> > have enabled that for a TObject descendant with {$M+} compiler
> > directives.
> > 
> > 
> > TCustomApplication = Class(TComponent)
> > ....
> > end;
> 
> It most probably is not unknown to you: the most important benefit of 
> being TComponent is that you can be owner of other components, so
> that eases memory management. The Application can become responsible
> for freeing the components it owns.

And don't forget the second feature. Via FreeNotification Application
is notified, when a component is freed.


Mattias



More information about the fpc-devel mailing list