DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2780
Version: 1.3-feature


Domingo, your proposal is indeed something that came to my mind recently.
We should include it in FLTK anyway, although the loop could cost some
time, if there are some more widgets in the delete queue.

That said, your code and your comments show some potential problems:

(1) It will not delete "all" windows, but only those that are currently
shown, since only shown windows are in the list of windows. Maybe these
are "all" windows in your case, but not in general.

(2) You must only delete windows created with "new", not statically
allocated windows, or those created as local variables in main().
Otherwise those windows will be deleted twice. The 2nd deletion will occur
on exit, when the local variables go out of scope, or later, when d'tors
for static variables will be called.

(3) You wrote: "I do call Fl::delete_widget from destructor of other
windows too". This is bad program design and should be avoided. I'd
compare this to: "I have two pointers to an object, and I delete this
object with both pointers". This is something you must not do.

Fl::delete_widget() is NOT intended to avoid multiple deletion of objects,
but only to postpone the real deletion until after the current event has
been processed completely.

Note: Fl::delete_widget() was an "invention" of FLTK 1.1, because some
code introduced in the library made applications crash, if widgets
(windows, buttons, or others) were deleted during their own callbacks.
This problem has been solved in FLTK 1.3, and it is possible (although not
very likely, and not really planned yet) that Fl::delete_widget() will be
removed or replaced with a direct call to delete in a later FLTK version
(maybe 3.0). You should not rely on its current behavior.


Link: http://www.fltk.org/str.php?L2780
Version: 1.3-feature

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

Reply via email to