Hi all,
Please take a look at the code below:
class MyClass : public Fl_Window {
Fl_Button *butt;
Fl_Button *butt2;
Fl_Box *box;
void my_callback(Fl_Widget *w)
{
begin();
box = new Fl_Box(10,40, 100, 100);
box->box(FL_DOWN_BOX);
box->color((Fl_Color) FL_WHITE);
end();
redraw();
}
void my_callback2(Fl_Widget *w) {
if(box) box->hide();
}
static void my_static_callback(Fl_Widget *w, void *data) {
((MyClass*)data)->my_callback(w);
}
static void my_static_callback2(Fl_Widget *w, void *data) {
((MyClass*)data)->my_callback2(w);
}
public:
MyClass(int X, int Y):Fl_Window(X,Y) {
butt = new Fl_Button(5,10,90,25,"Display");
butt2 = new Fl_Button(105,10,90,25,"Clear");
butt->callback(my_static_callback, (void*)this);
butt2->callback(my_static_callback2, (void*)this);
box = 0;
end();
}
};
int main(int argc, char **argv) {
MyClass myclass(200,200);
myclass.show(argc, argv);
return Fl::run();
}
In the "my_callback2" static function, the box is hidden when user press the
clear button.
Everything works fine with the hide() method.
But, (for some reasons) I'd rather delete the box (and release the allocated
memory) instead to hide it. So I replaced box->hide() with
Fl::delete_widget(box).
Now the app crash when the clear button is pressed.
What do I did wrong ?
Thanks
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk