Re: [fltk/fltk] Tree & delete node (as button), 1.3.6, linux (#251)
Albrecht Schlosser
Jul 13, 2021
FTR: deleting a widget and removing it from its parent (Fl_Group) is as simple as delete w;. This is documented, for instance in the destructor (~Fl_Widget) docs.
There are some details in the docs of Fl::delete_widget() as well. The automatic removal from its parent group was obviously (as documented) introduced in 1.3.0.
Side note: Fl::delete_widget() should no longer be necessary since FLTK 1.3.x (which exact x I do not know). It has always only be recommended if you wanted to delete a widget in its own callback (directly or indirectly [1]), but I hope that this is no longer necessary because we fixed the access-after-delete issues we had in 1.1.x. However, there's no official guarantee. Personally I would always call delete w in FLTK 1.4 (and 1.3) rather than using Fl::delete_widget(w);.
[1] with indirectly I mean deleting one of the parents of a widget which would recursively delete the widget itself, e.g. delete button->parent() or something like that.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.