diff options
author | corvid <corvid@lavabit.com> | 2011-08-01 04:37:16 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2011-08-01 04:37:16 +0000 |
commit | 9622febaa54bdfca3927912d7f544447b3780c4c (patch) | |
tree | f5cb5a42bd73d56486055ef3430ac01536c20c55 /dw | |
parent | 22662f0bd143db428e143ce73b3216487991a682 (diff) |
deal with Fl_Text_Buffer::text() returning a copy
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkui.cc | 11 | ||||
-rw-r--r-- | dw/fltkui.hh | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 788df084..f071d910 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -605,6 +605,7 @@ FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, FltkSpecificResource <dw::core::ui::MultiLineTextResource> (platform) { buffer = new Fl_Text_Buffer; + text_copy = NULL; editable = false; numCols = cols; @@ -628,6 +629,8 @@ FltkMultiLineTextResource::~FltkMultiLineTextResource () /* Free memory avoiding a double-free of text buffers */ ((Fl_Text_Editor *) widget)->buffer (0); delete buffer; + if (text_copy) + free(text_copy); } Fl_Widget *FltkMultiLineTextResource::createNewWidget (core::Allocation @@ -678,7 +681,13 @@ void FltkMultiLineTextResource::sizeRequest (core::Requisition *requisition) const char *FltkMultiLineTextResource::getText () { - return buffer->text (); + /* FLTK-1.3 insists upon returning a new copy of the buffer text, so + * we have to keep track of it. + */ + if (text_copy) + free(text_copy); + text_copy = buffer->text(); + return text_copy; } void FltkMultiLineTextResource::setText (const char *text) diff --git a/dw/fltkui.hh b/dw/fltkui.hh index a5bddc5a..ff927c80 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -316,6 +316,7 @@ class FltkMultiLineTextResource: { private: Fl_Text_Buffer *buffer; + char *text_copy; bool editable; int numCols, numRows; |