summaryrefslogtreecommitdiff
path: root/framebuffer/fbtk
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-10-23 19:58:20 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-10-23 19:58:20 +0100
commite1a96ecfe1735e916156bfe9e9c06196116caadd (patch)
treee57b7e6cd050e588a5d1ebd153d16a7bc27f29bf /framebuffer/fbtk
parent182b97ed3354fcdd4dfb3de54bf7afdf32c6365d (diff)
downloadnetsurf-e1a96ecfe1735e916156bfe9e9c06196116caadd.tar.gz
netsurf-e1a96ecfe1735e916156bfe9e9c06196116caadd.tar.bz2
Register destruction callback to free text widget text.
Diffstat (limited to 'framebuffer/fbtk')
-rw-r--r--framebuffer/fbtk/text.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index f3c88baef..a4562289b 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -169,6 +169,27 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
return 0;
}
+/** Text destroy callback.
+ *
+ * Called when a text widget is destroyed.
+ *
+ * @param widget The widget being destroyed.
+ * @param cbi The callback parameters.
+ * @return The callback result.
+ */
+static int fb_destroy_text(fbtk_widget_t *widget, fbtk_callback_info *cbi)
+{
+ if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_TEXT)) {
+ return 0;
+ }
+
+ if (widget->u.text.text != NULL) {
+ free(widget->u.text.text);
+ }
+
+ return 0;
+}
+
/** Text button redraw callback.
*
* Called when a text widget requires redrawing.
@@ -545,6 +566,7 @@ fbtk_create_text(fbtk_widget_t *parent,
neww->u.text.outline = outline;
fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_text, NULL);
+ fbtk_set_handler(neww, FBTK_CBT_DESTROY, fb_destroy_text, NULL);
return neww;
}
@@ -574,6 +596,7 @@ fbtk_create_writable_text(fbtk_widget_t *parent,
neww->u.text.pw = pw;
fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_text, NULL);
+ fbtk_set_handler(neww, FBTK_CBT_DESTROY, fb_destroy_text, NULL);
fbtk_set_handler(neww, FBTK_CBT_CLICK, text_input_click, pw);
fbtk_set_handler(neww, FBTK_CBT_STRIP_FOCUS, text_input_strip_focus, NULL);
fbtk_set_handler(neww, FBTK_CBT_INPUT, text_input, neww);
@@ -603,6 +626,7 @@ fbtk_create_text_button(fbtk_widget_t *parent,
neww->u.text.outline = true;
fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_text_button, NULL);
+ fbtk_set_handler(neww, FBTK_CBT_DESTROY, fb_destroy_text, NULL);
fbtk_set_handler(neww, FBTK_CBT_CLICK, click, pw);
fbtk_set_handler(neww, FBTK_CBT_POINTERENTER, fbtk_set_ptr, &hand_image);