Author: AlbrechtS
Date: 2010-09-27 04:29:05 -0700 (Mon, 27 Sep 2010)
New Revision: 7705
Log:
Fixed undefined behavior of fl_choice and others when closing
the message window instead of using a button (STR 2418).


Modified:
   branches/branch-1.3/src/fl_ask.cxx

Modified: branches/branch-1.3/src/fl_ask.cxx
===================================================================
--- branches/branch-1.3/src/fl_ask.cxx  2010-09-09 15:59:20 UTC (rev 7704)
+++ branches/branch-1.3/src/fl_ask.cxx  2010-09-27 11:29:05 UTC (rev 7705)
@@ -65,8 +65,13 @@
 
 static char avoidRecursion = 0;
 
-// sets the global return value (ret_val) and closes the window
-static void button_cb(Fl_Widget *bt, void *val) {
+// Sets the global return value (ret_val) and closes the window.
+// Note: this is used for the button callbacks and the window
+// callback (closing the window with the close button or menu).
+// The first argument (Fl_Widget *) can either be an Fl_Button*
+// pointer to one of the buttons or an Fl_Window* pointer to the
+// message window (message_form).
+static void button_cb(Fl_Widget *, void *val) {
   ret_val = (int)(long)val;
   message_form->hide();
 }
@@ -82,6 +87,7 @@
  Fl_Group::current(0);
  // create a new top level window
  Fl_Window *w = message_form = new Fl_Window(410,103,"");
+ message_form->callback(button_cb,(void *)0);
  // w->clear_border();
  // w->box(FL_UP_BOX);
  (message = new Fl_Box(60, 25, 340, 20))

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to