DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New] Link: http://www.fltk.org/str.php?L2494 Version: 1.3-feature Here there is some code corrections and a simple project as example. For this to work with stack/auto widgets we need a new flag: Fl_Widget.H -> ON_GROUP_ONLY_REMOVE = 1<<25, ///< Fl_Group should only remove this widget without apply free on it And a modification to Fl_Group.cxx on method Fl_Group::clear() ---- while (children_) { // delete all children int idx = children_-1; // last child's index Fl_Widget* w = child(idx); // last child widget if (w->parent()==this) { // should always be true if (children_>2) { // optimized removal w->parent_ = 0; // reset child's parent children_--; // update counter } else { // slow removal remove(idx); } if(!w->flags() & ON_GROUP_ONLY_REMOVE) delete w; // delete the child } else { // should never happen remove(idx); // remove it anyway } } ---- This modifications are invisible to existing applications but if we want touse automatic/stack widgets with dynamic allocated Windows/Groups then we need to set this flag on our automatic/stack widgets to prevent double free (one on the dynamig window/group release and another by the compiler at the end of the local scope). Also to use automatic/stack variables on fluid we need to inform it when supplying widget names: widget name : age //an widget that fluid will generate code to create it widget name : @age //a pointer to a widget that fluid will reuse widget name : @&age //an automatic/stack widget that fluid will reuse On the example attached I use automatic/stack widgets, to ease of use I derived then, using a macro, where I have a constructor that don't need any arguments and sets the flag ON_GROUP_ONLY_REMOVE. On the dialog created on fluid I have an automatic/stack instance of AddressEdit (wich supply most of the widgets used) and reuse it's widgets with fluid. Link: http://www.fltk.org/str.php?L2494 Version: 1.3-feature _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
