Index: uim.c =================================================================== --- uim.c (revision 5477) +++ uim.c (working copy) @@ -76,7 +76,7 @@ void uim_anthy_utf8_plugin_instance_quit(void); #endif -static uim_bool uim_initialized; +static unsigned int uim_init_count; static uim_lisp protected0, protected1; @@ -96,7 +96,8 @@ int ret; char *sys_load_path; - if (uim_initialized) + uim_init_count++; + if (uim_init_count != 1) return OK; uim_init_error(); @@ -157,22 +158,21 @@ uim_scm_require_file("init.scm"); - uim_initialized = UIM_TRUE; - return (void *)OK; } void uim_quit(void) { - if (!uim_initialized) - return; - if (UIM_CATCH_ERROR_BEGIN()) { - /* Leave uim_initialized uncleared to keep libuim disabled. */ + /* Leave uim_init_count untouched to keep libuim disabled. */ return; } + uim_init_count--; + if (uim_init_count != 0) + return; + uim_quit_plugin(); #ifdef ENABLE_ANTHY_STATIC uim_anthy_plugin_instance_quit(); @@ -184,7 +184,6 @@ uim_notify_quit(); #endif uim_scm_quit(); - uim_initialized = UIM_FALSE; } uim_context