X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fwindow.c;h=31b157f17077278a3b01bb357f4308acb882eade;hb=cbd4cb7f8c62b2ba51329a4cb082a96115a7529d;hp=5cef17eee064870c5a9395e4bd4a4a738b20b9df;hpb=13b21e2a9ba53c7109ae0bbfd774f16f0c9d4413;p=rodin%2Fchimara.git diff --git a/libchimara/window.c b/libchimara/window.c index 5cef17e..31b157f 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -41,28 +41,39 @@ window_new_common(glui32 rock) return win; } +/* Internal function: window closing stuff that is safe to call from either the + main thread or the Glk thread. */ +void +trash_window_thread_independent(ChimaraGlkPrivate *glk_data, winid_t win) +{ + win->magic = MAGIC_FREE; + + g_list_foreach(win->history, (GFunc)g_free, NULL); + g_list_free(win->history); + + g_string_free(win->buffer, TRUE); + g_hash_table_destroy(win->hyperlinks); + g_free(win->current_hyperlink); + g_free(win); +} + +/* Internal function: do all the stuff necessary to close a window. Call only + from Glk thread. */ static void window_close_common(winid_t win, gboolean destroy_node) { ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + if(glk_data->unregister_obj) { (*glk_data->unregister_obj)(win, gidisp_Class_Window, win->disprock); win->disprock.ptr = NULL; } - + if(destroy_node) g_node_destroy(win->window_node); - win->magic = MAGIC_FREE; - - g_list_foreach(win->history, (GFunc)g_free, NULL); - g_list_free(win->history); - - g_string_free(win->buffer, TRUE); - g_hash_table_destroy(win->hyperlinks); - g_free(win->current_hyperlink); - g_free(win); + + trash_window_thread_independent(glk_data, win); } /**