On 05/30/12 09:12, Albrecht Schlosser wrote:
> On 30.05.2012 16:55, Greg Ercolano wrote:
>> When you hit ESC, fltk has already deleted the widgets.
>
> That's not true. As said before, all windows have been closed by
> calling hide() on them, but they have NOT been destroyed (by FLTK),
> unless you did it explicitly in your code.
Ah, you're right.
I've always thought of it this way, because I always have
the program exit after Fl::run() returns, which by definition
is when all windows have 'closed', but that really means 'hidden',
ie. a GUI program is usually done if it has no visible windows
to interact with the user.
>> Doing the delete's outside the Fl::run() is redundant,
>> causing the undefined behavior; by that time, the pointers
>> are wild.
>
> See above. If you take this as an example for creating and deleting
> windows over and over again, then it is correct to delete the window
> after it has been hidden. The code given seems to be correct, AFAICT.
> In earlier versions of FLTK (1.1) it was important to use
> Fl::delete_widget() instead of using delete directly, but this
> shouldn't be necessary any more, especially not if the window has
> already been closed and Fl::run() has exited.
I'm still living in the past, apparently.
Perhaps our section on 1.1 -> 1.3 should cover this:
http://fltk.org/doc-1.3/migration_1_3.html
Do we have a section on deleting widgets now?
I thought there was at least an article on this,
but couldn't find it when replying to David's post.
I did only find this section:
http://fltk.org/doc-1.3/group__fl__del__widget.html
But its more a reference, and doesn't cover the philosophy
of memory management. ie. when a program should use new
and when to use delete, as it's often not symmetrical
in practice, due to automated destructors.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev