From d37bc67158228e75dc4f47cf445c771a890fb35a Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 8 Apr 2015 01:16:22 -0400 Subject: Cleaned up memory leaks in the GTK+ backend. --- new/button_unix.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'new/button_unix.c') diff --git a/new/button_unix.c b/new/button_unix.c index 986e81d..8ab9aa6 100644 --- a/new/button_unix.c +++ b/new/button_unix.c @@ -19,7 +19,13 @@ static void defaultOnClicked(uiControl *c, void *data) // do nothing } -// TODO destruction +static void onDestroy(GtkWidget *widget, gpointer data) +{ + struct button *b = (struct button *) data; + + uiFree(b); +} + uiControl *uiNewButton(const char *text) { struct button *b; @@ -33,6 +39,7 @@ uiControl *uiNewButton(const char *text) NULL); widget = GTK_WIDGET(uiControlHandle(b->c)); + g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), b); g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), b); b->onClicked = defaultOnClicked; -- cgit v1.2.3