diff --git a/gui/idle.c b/gui/idle.c index 79dc6208..31e962b0 100644 --- a/gui/idle.c +++ b/gui/idle.c @@ -5,6 +5,8 @@ #include #include +static guint idle_id = 0; + static gboolean __on_idle(gpointer data) { GtkProgressBar *progress = GTK_PROGRESS_BAR(data); @@ -14,6 +16,7 @@ static gboolean __on_idle(gpointer data) return gtk_widget_is_visible(gui_builder_widget("o_window")); } else { gtk_widget_hide(GTK_WIDGET(progress)); + idle_id = 0; return G_SOURCE_REMOVE; } } @@ -23,5 +26,12 @@ void gui_idle_enable() GtkWidget *progress = gui_builder_widget("o_idle_progress"); gtk_widget_show(progress); - g_idle_add(__on_idle, progress); + idle_id = g_idle_add(__on_idle, progress); +} + +void gui_idle_disable() +{ + if (idle_id) + g_source_remove(idle_id); + idle_cancel(); } diff --git a/gui/ocarina.c b/gui/ocarina.c index c9e0ff9d..bfb37f28 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -2,7 +2,6 @@ * Copyright 2014 (c) Anna Schumaker. */ #include -#include #include #include #include @@ -75,7 +74,7 @@ static void __ocarina_startup(GApplication *application, gpointer data) static void __ocarina_shutdown(GApplication *application, gpointer data) { - idle_cancel(); + gui_idle_disable(); core_deinit(); gui_window_deinit(); diff --git a/include/gui/idle.h b/include/gui/idle.h index 0101751a..e579c268 100644 --- a/include/gui/idle.h +++ b/include/gui/idle.h @@ -7,4 +7,7 @@ /* Called to enable processing idle queue tasks. */ void gui_idle_enable(); +/* Called to disable processing idle queue tasks. */ +void gui_idle_disable(); + #endif /* OCARINA_GUI_IDLE_H */