X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fchimara-glk.c;h=949f951d084669a9664115964d9225d67ac8b65c;hb=b2e519687ab410b6489b3ec02348ec5251e81b05;hp=47c2b51b014b320d625bfabc3cf1147d004902af;hpb=e2c1b09185cc77cdc1245e0c12caab4d7b0e7f6d;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 47c2b51..949f951 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -1257,8 +1257,7 @@ chimara_glk_run(ChimaraGlk *glk, const gchar *plugin, int argc, char *argv[], GE g_assert( g_module_supported() ); /* If there is already a module loaded, free it first -- you see, we want to * keep modules loaded as long as possible to avoid crashes in stack unwinding */ - if( priv->program && !g_module_close(priv->program) ) - g_warning( "Error closing module :%s", g_module_error() ); + chimara_glk_unload_plugin(glk); /* Open the module to run */ priv->program = g_module_open(plugin, G_MODULE_BIND_LAZY); @@ -1356,6 +1355,26 @@ chimara_glk_wait(ChimaraGlk *glk) gdk_threads_enter(); } +/** + * chimara_glk_unload_plugin: + * @glk: a #ChimaraGlk widget + * + * The plugin containing the Glk program is unloaded as late as possible before + * loading a new plugin, in order to prevent crashes while printing stack + * backtraces during debugging. Sometimes this behavior is not desirable. This + * function forces @glk to unload the plugin running in it. + * + * This function does nothing if there is no plugin loaded. + */ +void +chimara_glk_unload_plugin(ChimaraGlk *glk) +{ + g_return_if_fail(glk || CHIMARA_IS_GLK(glk)); + CHIMARA_GLK_USE_PRIVATE(glk, priv); + if( priv->program && !g_module_close(priv->program) ) + g_warning( "Error closing module :%s", g_module_error() ); +} + /** * chimara_glk_get_running: * @glk: a #ChimaraGlk widget