DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2302
Version: 1.1.10
Callbacks for widgets without callbacks are queued in the internal queue
that can be read with Fl::readqueue(). Currently it is possible that
widgets are deleted before the queue is read, and that the widgets created
by fl_alert(), fl_message() etc. get the same memory address as the
previously deleted widgets. This results in closing the popup window
immediately.
There may not be a high probability that this happens, but it is
reproducible with the attached test program alert.cxx
Link: http://www.fltk.org/str.php?L2302
Version: 1.1.10
/*
Here's a (minimal) implementation of my problem. When I click the
lower button, fl_alert() appears and suddenly closes as if a mouse
click was still pending.
I use FLTK 1.1.9 with CodeBlocks (MinGW)and WinXP.
posted by N. Cassetta in fltk.general on Dec 22, 2009
subject: fl_alert() closes immediately
*********************************************************************
*/
#include <cstdio>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <Fl/Fl_Toggle_button.H>
#include <Fl/Fl_Message.H>
class MyWin : public Fl_Window {
public:
MyWin();
int handle(int e);
private :
static void exit_cb(Fl_Widget* w, void *p);
Fl_Toggle_Button* Btnum[10];
Fl_Button* Btnumok;
};
MyWin::MyWin() : Fl_Window(400, 180, 118, 125) {
char s[3];
for (int c = 0; c < 9; c++) {
Btnum[c] = new Fl_Toggle_Button (10+34*(c%3), 2+32*(c/3), 30, 30);
sprintf(s, "%d", c+1);
Btnum[c]->copy_label(s);
// Btnum[c]->when(FL_WHEN_NEVER); // add this to avoid the problem
}
Btnumok = new Fl_Button(10, 100, 46, 20, "Ok");
Btnumok->callback(exit_cb);
end();
set_modal();
show();
}
int MyWin::handle (int event) {
int ret = Fl_Window::handle(event);
if (event == FL_PUSH) {
int num = find(Fl::pushed());
if (num > 8) return 1; // OK was pressed
// else do something
}
return ret;
}
void MyWin::exit_cb(Fl_Widget* w, void* p) {
// do something
w->window()->hide();
}
//**************************************************************************************
class MyBox : public Fl_Box {
public:
MyBox(int x, int y, int w, int h, char* l) : Fl_Box(x, y, w, h, l)
{box(FL_UP_BOX); }
protected :
int handle(int event);
};
int MyBox::handle (int event) {
if (event == FL_PUSH) {
MyWin* MW = new MyWin();
label ("Click numbers and then OK");
while (MW->shown()) Fl::wait();
delete MW;
return 1;
}
return Fl_Box::handle(event);
}
//**************************************************************************************
void showalert_cb(Fl_Widget* w, void* p) {
fl_alert("This disappears!");
}
int main (int argc, char ** argv) {
Fl_Window *window;
Fl_Button *w;
window = new Fl_Window (300, 180);
new MyBox (20, 40, 200, 30, "First click here");
w = new Fl_Button(20, 100, 100, 30, "Then here");
w->callback(showalert_cb);
window->show();
return(Fl::run());
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs