aboutsummaryrefslogtreecommitdiff
path: root/dw/fltkui.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-08-01 04:37:16 +0000
committercorvid <corvid@lavabit.com>2011-08-01 04:37:16 +0000
commit9622febaa54bdfca3927912d7f544447b3780c4c (patch)
treef5cb5a42bd73d56486055ef3430ac01536c20c55 /dw/fltkui.cc
parent22662f0bd143db428e143ce73b3216487991a682 (diff)
deal with Fl_Text_Buffer::text() returning a copy
Diffstat (limited to 'dw/fltkui.cc')
-rw-r--r--dw/fltkui.cc11
1 files changed, 10 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)