X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fabort.c;h=9ee66fc3bc6ff1eb1a98b3ba16107796ffbd97ce;hb=HEAD;hp=28e33fae444c5d85e64b29232d3b08d58b99572e;hpb=1589fbfcd406df40d8da4f078dad3327c4862871;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/abort.c b/libchimara/abort.c index 28e33fa..9ee66fc 100644 --- a/libchimara/abort.c +++ b/libchimara/abort.c @@ -6,7 +6,7 @@ #include "chimara-glk-private.h" #include "window.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * glk_set_interrupt_handler: @@ -31,7 +31,7 @@ extern GPrivate *glk_data_key; void glk_set_interrupt_handler(void (*func)(void)) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); glk_data->interrupt_handler = func; } @@ -40,13 +40,13 @@ user's interrupt handler. */ static void abort_glk(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->interrupt_handler) (*(glk_data->interrupt_handler))(); shutdown_glk_pre(); shutdown_glk_post(); /* If program is terminated by g_thread_exit() instead of returning from the - glk_main() function, then the line in glk_enter() where the "stopped" + glk_main() function, then the line in glk_exit() where the "stopped" signal is emitted will not be reached. So we have to emit it here. */ if(!glk_data->in_startup) g_signal_emit_by_name(glk_data->self, "stopped"); @@ -57,14 +57,14 @@ abort_glk(void) void check_for_abort(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - g_mutex_lock(glk_data->abort_lock); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + g_mutex_lock(&glk_data->abort_lock); if(glk_data->abort_signalled) { - g_mutex_unlock(glk_data->abort_lock); + g_mutex_unlock(&glk_data->abort_lock); abort_glk(); } - g_mutex_unlock(glk_data->abort_lock); + g_mutex_unlock(&glk_data->abort_lock); } /* Internal function: shut down all requests and anything not necessary while @@ -72,8 +72,8 @@ check_for_abort(void) void shutdown_glk_pre(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Stop any timers */ glk_request_timer_events(0); @@ -113,18 +113,18 @@ shutdown_glk_pre(void) ; /* Wait for any pending window rearrange */ - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); if(glk_data->needs_rearrange) - g_cond_wait(glk_data->rearranged, glk_data->arrange_lock); - g_mutex_unlock(glk_data->arrange_lock); + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); } /* Internal function: do any Glk-thread cleanup for shutting down the Glk library. */ void shutdown_glk_post(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Free all opaque objects; can't iterate normally, because the objects are being removed from the global iteration lists */ if(glk_data->root_window) @@ -141,22 +141,22 @@ shutdown_glk_post(void) glk_schannel_destroy(sch); /* Empty the event queue */ - g_mutex_lock(glk_data->event_lock); + g_mutex_lock(&glk_data->event_lock); g_queue_foreach(glk_data->event_queue, (GFunc)g_free, NULL); g_queue_clear(glk_data->event_queue); - g_mutex_unlock(glk_data->event_lock); - + g_mutex_unlock(&glk_data->event_lock); + /* Reset the abort signaling mechanism */ - g_mutex_lock(glk_data->abort_lock); + g_mutex_lock(&glk_data->abort_lock); glk_data->abort_signalled = FALSE; - g_mutex_unlock(glk_data->abort_lock); - + g_mutex_unlock(&glk_data->abort_lock); + /* Reset arrangement mechanism */ - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); glk_data->needs_rearrange = FALSE; glk_data->ignore_next_arrange_event = FALSE; - g_mutex_unlock(glk_data->arrange_lock); - + g_mutex_unlock(&glk_data->arrange_lock); + /* Unref input queues (they are not destroyed because the main thread stil holds a ref */ g_async_queue_unref(glk_data->char_input_queue); g_async_queue_unref(glk_data->line_input_queue); @@ -170,6 +170,4 @@ shutdown_glk_post(void) glk_data->unregister_obj = NULL; glk_data->register_arr = NULL; glk_data->unregister_arr = NULL; - - /* Leave the style_initialized flag as it is, since the CSS file is a widget property */ }