On Wed, Dec 19, 2007 at 06:34:19PM +0100, Johannes Hofmann wrote:
When you leave a page that has a textarea field you get a double free(). The TextBuffer is deleted first, then the TextEditor widgets are deleted and these access member methods of of the TextBuffer in their destructors.
Ouch! Yes, since the derived class manages the buffer and the superclass manages the widgets C++ insists on deleting the buffer first.
I have no idea yet how to fix this. Perhaps we can disassociate the TextBuffer from the TextEditor widgets in the FltkMultiLineTextResource destructor before deleting it?
I think we must, since we have no way of postponing the deletion of the buffer. Here's the patch. Jeremy Henty diff -pru -- dw2-ref/dw/fltkui.cc dw2-cur/dw/fltkui.cc --- dw2-ref/dw/fltkui.cc 2007-12-19 14:13:25.000000000 +0000 +++ dw2-cur/dw/fltkui.cc 2007-12-19 21:10:16.000000000 +0000 @@ -541,6 +541,11 @@ FltkMultiLineTextResource::FltkMultiLine FltkMultiLineTextResource::~FltkMultiLineTextResource () { + for (Iterator <ViewAndWidget> it = viewsAndWidgets->iterator (); + it.hasNext(); ) { + ViewAndWidget *viewAndWidget = it.getNext (); + ((::fltk::TextEditor *) viewAndWidget->widget)->buffer (0); + } delete buffer; }