summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/widgets/textbox.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 5f588bd9..04dfc7d2 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -334,6 +334,14 @@ void textbox_text ( textbox *tb, const char *text )
void textbox_icon ( textbox *tb, cairo_surface_t *icon )
{
+ // Add our reference to the surface.
+ if ( icon != NULL ) {
+ cairo_surface_reference ( icon );
+ }
+ if ( tb->icon ) {
+ // If we overwrite an old one, destroy the reference we hold.
+ cairo_surface_destroy ( tb->icon );
+ }
tb->icon = icon;
widget_queue_redraw ( WIDGET ( tb ) );
@@ -390,6 +398,10 @@ static void textbox_free ( widget *wid )
}
g_free ( tb->text );
+ if ( tb->icon ) {
+ cairo_surface_destroy ( tb->icon );
+ tb->icon = NULL;
+ }
if ( tb->layout != NULL ) {
g_object_unref ( tb->layout );
}