On Friday 22 June 2007 23:22, Marc Weustink wrote:
> zeljko wrote:
> > On Friday 22 June 2007 14:51, Marc Weustink wrote:
> >> zeljko wrote:
> >>> Compiled simple project with -gh , and it seem that TForm doesn't call
> >>> Free() for it's children (created at design time) eg.
> >>>
> >>> MainForm -> Form1 ->
> >>>                       -> TRadioGroup with 4 radio buttons
> >>>                       -> TButton -> calls Close() of Form1.
> >>>
> >>> Tested under linux with:
> >>> gtk, gtk2, qt - fpc- 2.0.4
> >>>
> >>> If I explicitely call Free() for each of children in Form1.OnClose()
> >>> then it calls children's destructors, but still remains unfreed blocks
> >>> for form itself ?!?
> >>>
> >>> compiler ? lcl ?  any ?
> >>
> >> You don't get an exception or so ?
> >>
> >> I wonder if it is allowed to call close in an eventhandler of the same
> >> form. If the form gets freed, one should use Release.
> >
> > I didn't call Free() for form itself, just for it's children, because
> > I've founded that eg. DestroyHandle() is not called (for children
> > controls).
>
> But, doesn't the close indirectly call free ?

heaptrace says not. Here are tests:

Form = TForm2 + one TEdit + one TButton.
1. Create form (with n children) while application starts (autocreate).
RESULT = OK (all clear)

2. Create form (with n children) like with TForm2.Create(Self) do ...
RESULT = OK (all clear)

3. Create form (with n children) like with TForm2.Create(NIL) do ...
RESULT = NOT OK, heaptrc screams about unfreed memory blocks
Adding CloseAction = caFree in OnClose event of form do the job here ...

So is it "a must" to add CloseAction := caFree while closing form created with 
NiL parameter ?

Tested on Linux , gtk+, lazarus 20070622, fpc-2.0.4 - 20070622

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to