Thanks gentlemen for your answers.
Fl::delete_widget() solved the problem.
I'm sorry that I didn't search enough in the docs before asking.
David
> David Lopez wrote:
> > Hi, I am migrating an application from FLTK 1.1.3 to FLTK 1.1.9.
> > The problem is the following
> > I have a button whose callback deletes the button itself.
> >
> > It works fine in 1.1.3, since the code for Fl_Widget::do_callback is the
> > following:
> > void do_callback() {callback_(this,user_data_);}
> >
> > But in 1.1.9 that code changed to:
> > void do_callback() {callback_(this,user_data_); if (callback_ !=
> > default_callback) clear_changed();}
>
> Yes, this was added in 1.1.5 (unfortunately).
>
> > So, the instruction clear_changed() executes after the object was
> > destroyed, causing a crash.
> >
> > The question is, isn't valid to delete a widget in its callback?
>
> This has been discussed more than once, and some people (including me)
> say that it ought to be possible, but it is not guranteed to work
> in all cases. :-( I'm trying to improve this in FLTK 1.3, but this
> is still work in progress.
>
> > In such case, what would you suggest doing?
>
> (1) If you can: hide the button instead of deleting it, or remove
> it from the group w/o deleting it.
>
> (2) Use FLTK 1.3 instead. This particular crash can't happen with
> FLTK 1.3, because widget deletion is checked in this case.
>
> (3) Use Fl::delete_widget() as others wrote before.
>
> Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk