>> Actually, you're not supposed to delete FLTK widgets with C++ delete,
>> FLTK must handle the deletion to ensure the widget(s) are properly
>> disconnected from the widget tree correctly.
>>
>> I believe what you want is Fl::delete_widget() which will schedule
>> the deletion when you return to the application loop.
>> http://fltk.org/documentation.php/doc-1.1/Fl.html#Fl.delete_widget
>>
>> There should probably be a special section in the docs about
>> deleting widgets (if there isn't already one), as this seems to
>> come up a lot on the newsgroup.
>
> The delete_widget() method, as documented, is supposed to handle
> the important special case of deletion from within a callback.
> It was thoughtful of the designers to think of this.
Ya, delete_widget() was added relatively recently..
in 1.1.6 according to the CHANGES log.
> As for being "not supposed to delete FLTK widgets..," if this were
> really the case (and, with due respect to Greg, I really doubt it),
> fltk would simply be broken.
You're probably right, I might be wrong on that due to dated info
and hazy memory. Threads on deleting widgets have historically
been large on this group due to caveats.
At best, I remember deleting widgets had to be done /carefully/
to ensure fltk didn't have leftover info after the delete. It
used to be the case that if you delete'ed a widget, fltk still
kept the pointer to it, such that when the window was destroyed,
/fltk/ would try to delete the widget again.
I believe the recommended pattern was Fl_Group::remove() + delete
to ensure FLTK didn't also try to remove it when you returned
to the app loop. There were some caveats to that too.. I always had
to look at FLTK's own code to see what the right approach was.
I'll yield to ian/matt/mike and the other core folks on this
as they seemed to know those details better than I.
Would be great if deleting widgets was covered in the docs.
I think the reason it hasn't is because it has been evolving,
and there are several caveats (that should probably be listed)
depending on circumstances of when to delete (callbacks vs events)
and when delete is handled for you (exiting, window/group destruction)
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk