X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fabort.c;h=8399f054901376b1d1790bc2639d5c4a27c330cc;hb=cbd4cb7f8c62b2ba51329a4cb082a96115a7529d;hp=5a812cfc200ac4ba9d7b75a9688a414f94146a4d;hpb=603af762db13e7b95a7c0931e7178ce44ff8ee21;p=rodin%2Fchimara.git diff --git a/libchimara/abort.c b/libchimara/abort.c index 5a812cf..8399f05 100644 --- a/libchimara/abort.c +++ b/libchimara/abort.c @@ -4,6 +4,7 @@ #include #include "chimara-glk-private.h" +#include "window.h" extern GPrivate *glk_data_key; @@ -66,13 +67,10 @@ shutdown_glk(void) { ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - if(!glk_data->in_startup) - g_signal_emit_by_name(glk_data->self, "stopped"); - /* Stop any timers */ glk_request_timer_events(0); - /* Cancel any pending input requests */ + /* Cancel any pending input requests and flush all window buffers */ winid_t win; for(win = glk_window_iterate(NULL, NULL); win; win = glk_window_iterate(win, NULL)) { @@ -90,6 +88,8 @@ shutdown_glk(void) default: ; /* Handle mouse and hyperlink requests */ } + + flush_window_buffer(win); } /* Close any open resource files */ @@ -102,6 +102,17 @@ shutdown_glk(void) g_async_queue_unref(glk_data->char_input_queue); g_async_queue_unref(glk_data->line_input_queue); - printf("cleaning up...\n"); - chimara_glk_reset(glk_data->self); + /* Wait for any pending window rearrange */ + 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); + + /* Default handler for 'stopped' unloads the plugin, so be absolutely sure + we're not calling any dispatch callbacks after this point */ + if(!glk_data->in_startup) + g_signal_emit_by_name(glk_data->self, "stopped"); + + _chimara_glk_free_nonwindow_private_data(glk_data); + glk_data->needs_reset = TRUE; }