summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2018-05-12 10:40:15 +0200
committerDave Davenport <qball@gmpclient.org>2018-05-12 10:40:15 +0200
commit2da5e5ee5568145884eebbeb1a012559466a644b (patch)
treee2104a2df76ac6eb7f8bbf71a4d6a7584860c0c4 /source
parentef6ace4333b92c9da4937265c0df71d43d6500cd (diff)
[TextBox] Add a reference to the cairo surface when displaying an icon.
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 );
}