On Wed, Mar 26, 2008 at 04:42:16PM +0000, place wrote:
Johannes wrote:
place wrote:
In FltkComplexButtonResource::createNewWidget, the button's child is a view. When the button is destroyed, since the button is a Group, its children get destroyed. Later on, the layout is being destroyed, and it deletes TopLevel. The toplevel widget destructor calls layout->removeWidget(), which tries to iterate through the views.
Ok I'm just trying to understand the ComplexButton button stuff - rather good class name btw :-) Why is there a view as child of the button? What is this view supposed to display?
I have no idea whether it's necessary. Maybe the layout in the button doesn't get shown otherwise?
Anyway, first I'd suggest:
diff -r f1f343e2c024 dw/fltkui.cc --- a/dw/fltkui.cc Tue Mar 18 18:05:51 2008 +0100 +++ b/dw/fltkui.cc Wed Mar 26 16:57:13 2008 +0100 @@ -423,13 +423,15 @@ if (!relief) button->box(::fltk::FLAT_BOX);
- button->begin (); lastFlatView = new FltkFlatView (allocation->x + reliefXThickness (), allocation->y + reliefYThickness (), allocation->width - 2 * reliefXThickness (), allocation->ascent + allocation->descent - 2 * reliefYThickness ()); + + button->add (lastFlatView); + if (layout) layout->attachView (lastFlatView); return button;
because this begin () / end () stuff is rather ugly, especially if the matching end () is missing.
Yes! At first, without the end(), I assumed the begin() was extraneous.
Sounds reasonable, but I'd really like to understand that ComplexButton stuff first. Is there something in doc/ I did not see? How did you know it is supposed to be used for image inputs?
In dw/ui.hh, it says
* <tr><td>image <td>dw::core::ui::ComplexButtonResource * <td>dw::core::ui::ResourceFactory::createComplexButtonResource, * width a dw::Image inside and relief = false.
Ahh, now I understand. layout is a new layout specific to the button. It is created in ComplexButton::init (). So the purpose of ComplexButton is to create buttons that can have arbitrary HTML rendered on them. I wonder if we really need to duplicate the button code from fltk for this. For now I think your fix is good. Perhaps we can make the whole stuff simpler in the future. Did you already manage to add an dw::Image to a ComplexButton? Cheers, Johannes