On 07/23/12 05:21, Furqan wrote:
> So, I am little bit less sure about this, is it a right way of de-allocation
> of all pointers?
It's hard to go wrong when you're quitting the application.
I usually just call exit() if I really want all the dtors called,
but unless there are lock files or some kind of external cleanup
unrelated to memory involved, I just call _exit() which skips the dtors,
and the program just exits.
When a process exits, all its ram is set free, so you don't have to
worry about expressly deallocating it all. In fact, that can often
make program exiting really slow, if you have a lot of memory allocated.
Calling exit() or _exit() frees all ram to the OS in one quick
operation.
What if the user click on the main FLTK window close button (top right corner
of the window)?
When the FLTK window's close button is clicked, it calls the window's
callback().
The default behavior is to just exit the program, but you can add some
code
to see if the user 'saved' their work (if this applies to your app), and
make the exit()/_exit() call an option only if everything has been
saved.
> Means can we call the destructor of the main window and put everything in
> that destructor which we want to de-allocate at the end of the session ?
exit() will call all your dtors, so you can just call that.
Or don't bother with all that and just call _exit().
Don't worry about 'memory leaks' or any kind of memory issues when
exiting the app; the OS frees it all when the process exits.
Killing an app with ^C or killing it from the Task Manager (Windows)
or with kill(1) (UNIX) does the same thing.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk