Thanks for the quick response!

Alright, the lifetime of the widgets in question is the liftime of the code, as 
are the strings I dynamically malloc, so then yes, the OS will free everything 
when the code exits.

Do the fltk widgets that u *new* within the top window get freed in this 
fashion upon exit? Or does fltk use some trick to delete the top level window 
upon exit, so that all children get destroyed?

I currently don't have any locally declared widgets, pretty much everything is 
getting newed. The class I made is just a wrapper for it all.

Cheers,
Dev

>
>
> > also made a destructor for the class, because I dynamically=20
> > create some strings, so I figured they need to be freed in=20
> > the destructor.=20
>
> If you destroy a fltk container widget (e.g. a group or a window) then
> it will destroy all its child widgets for you, so you do not have to. If
> you then try and destroy them again explicitly... Bad things.
>
> Any strings or etc you new/malloc you probably should delete/free, since
> fltk will not know about them (they are not fltk objects).
>
> However, IF the lifetime or you widgets is the lifetime of your code
> running (i.e. nothing gets deleted until the program exits) then you
> probably do not need to call the destructors at all (for anything) - the
> OS will automatically release any allocated resources, and will do so
> much more quickly and efficiently than calling the widget destructors
> ever can.
>
> The exception would be if the widget destructor performs some specific
> action that you depend on, in which case you probably would want to
> trigger it explicitly. This is not often necessary.
>
> Note: It is common for people to be taught that you *must* call the
> destructors for anything you *new* - but I'd suggest that the folk who
> teach this approach have never written any serious code...!
>
>
>
> SELEX Sensors and Airborne Systems Limited
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex=
>  SS14 3EL
> A company registered in England & Wales.  Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to