gui/idle: Add a function to disable processing idle tasks
This is needed during ocarina shutdown to prevent a segfault. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
fff2da5439
commit
bc513532c1
12
gui/idle.c
12
gui/idle.c
|
@ -5,6 +5,8 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/core.h>
|
||||
#include <core/idle.h>
|
||||
#include <gui/audio.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/collection.h>
|
||||
|
@ -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();
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue