Skip to content

Commit bc2bf15

Browse files
committed
fix: Santizer error on exit
Signed-off-by: onecoolx <onecoolx@gmail.com>
1 parent c16bd73 commit bc2bf15

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

test/gtk2/testGtk2.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ GdkPixbuf * pixb;
1717

1818
static ps_context *context;
1919
static ps_canvas *canvas;
20+
static guint timer_id = 0;
2021

2122
gboolean expose (GtkWidget *widget, GdkEventExpose *event)
2223
{
@@ -32,6 +33,10 @@ gboolean expose (GtkWidget *widget, GdkEventExpose *event)
3233

3334
void destroy(GtkWidget *widget, gpointer data)
3435
{
36+
if (timer_id > 0) {
37+
g_source_remove(timer_id);
38+
timer_id = 0;
39+
}
3540
dini_context(context);
3641
ps_context_unref(context);
3742
ps_canvas_unref(canvas);
@@ -110,7 +115,7 @@ int main(int argc, char* argv[])
110115

111116
g_signal_connect (G_OBJECT(drawarea), "expose_event", G_CALLBACK (expose), NULL);
112117

113-
g_timeout_add(10, time_func, GTK_WIDGET(drawarea));
118+
timer_id = g_timeout_add(10, time_func, GTK_WIDGET(drawarea));
114119

115120
gtk_container_add (GTK_CONTAINER (window), drawarea);
116121

0 commit comments

Comments
 (0)