summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Text_Buffer.H2
-rw-r--r--src/Fl_Text_Buffer.cxx6
2 files changed, 6 insertions, 2 deletions
diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H
index 36532d4d4..fbec504a6 100644
--- a/FL/Fl_Text_Buffer.H
+++ b/FL/Fl_Text_Buffer.H
@@ -188,7 +188,7 @@ public:
/**
Replaces the entire contents of the text buffer.
- \param text Text must be valid utf8.
+ \param text Text must be valid utf8. if null an empty string is substituted.
*/
void text(const char* text);
diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx
index 5b2f3a314..f2aaeb6c8 100644
--- a/src/Fl_Text_Buffer.cxx
+++ b/src/Fl_Text_Buffer.cxx
@@ -165,7 +165,11 @@ char *Fl_Text_Buffer::text() const {
void Fl_Text_Buffer::text(const char *t)
{
IS_UTF8_ALIGNED(t)
-
+
+ // if t is null then substitute it with an empty string
+ // then don't return so that internal cleanup can happen
+ if (!t) t="";
+
call_predelete_callbacks(0, length());
/* Save information for redisplay, and get rid of the old buffer */