Index: immodule-plugin.cpp =================================================================== --- immodule-plugin.cpp (revision 5483) +++ immodule-plugin.cpp (working copy) @@ -44,6 +44,7 @@ #include "immodule-plugin.h" #include "immodule-quiminputcontext_with_slave.h" #include "immodule-quiminfomanager.h" +#include "init-wrap.h" #if UIM_QT_USE_JAPANESE_KANA_KEYBOARD_HACK #include "uim/uim-x-util.h" @@ -121,7 +122,7 @@ void UimInputContextPlugin::uimInit() { - if ( !uim_init() ) { + if ( !uim_wrap_uim_init() ) { if (!infoManager) infoManager = new QUimInfoManager(); #if UIM_QT_USE_JAPANESE_KANA_KEYBOARD_HACK @@ -136,7 +137,7 @@ { if ( uimReady ) { - uim_quit(); + uim_wrap_uim_quit(); delete infoManager; uimReady = false; } Index: pref-qt.cpp =================================================================== --- pref-qt.cpp (revision 5483) +++ pref-qt.cpp (working copy) @@ -59,6 +59,7 @@ #include #include +#include "init-wrap.h" #include "qtgettext.h" #include @@ -70,7 +71,7 @@ : QDialog( parent, name ), m_isValueChanged( false ) { - uim_init(); + uim_wrap_uim_init(); if (uim_custom_enable()) { checkDotUimFile(); setupWidgets(); @@ -78,7 +79,7 @@ #if defined(ENABLE_DEBUG) qDebug("uim_custom_enable() failed."); #endif - uim_quit(); + uim_wrap_uim_quit(); QApplication::exit( -1 ); } @@ -87,7 +88,7 @@ UimPrefDialog::~UimPrefDialog() { - uim_quit(); + uim_wrap_uim_quit(); } void UimPrefDialog::checkDotUimFile() Index: immodule-quiminputcontext.cpp =================================================================== --- immodule-quiminputcontext.cpp (revision 5483) +++ immodule-quiminputcontext.cpp (working copy) @@ -58,6 +58,7 @@ #ifdef Q_WS_X11 #include "immodule-quiminputcontext_compose.h" #endif +#include "init-wrap.h" #if UIM_QT_USE_JAPANESE_KANA_KEYBOARD_HACK #include @@ -386,8 +387,8 @@ uim_release_context( ic->m_uc ); } - uim_quit(); - uim_init(); + uim_wrap_force_uim_quit(); + uim_wrap_uim_init(); infoManager->initUimInfo(); for ( ic = contextList.first(); ic; ic = contextList.next() ) Index: init-wrap.c =================================================================== --- init-wrap.c (revision 0) +++ init-wrap.c (revision 0) @@ -0,0 +1,62 @@ +/* + +Copyright (c) 2008 uim Project http://code.google.com/p/uim/ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +3. Neither the name of authors nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +*/ +#include + +#include "uim/uim.h" +#include "init-wrap.h" + +unsigned int uim_wrap_init_count; + +int uim_wrap_uim_init() +{ + uim_wrap_init_count++; + if (uim_wrap_init_count != 1) + return 0; + + return uim_init(); +} + +void uim_wrap_uim_quit() +{ + uim_wrap_init_count--; + if (uim_wrap_init_count != 0) + return; + + uim_quit(); +} + +void uim_wrap_force_uim_quit() +{ + uim_wrap_init_count = 0; + uim_quit(); +} Index: init-wrap.h =================================================================== --- init-wrap.h (revision 0) +++ init-wrap.h (revision 0) @@ -0,0 +1,49 @@ +/* + +Copyright (c) 2008 uim Project http://code.google.com/p/uim/ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +3. Neither the name of authors nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +*/ + +#ifndef UIM_QT_INIT_WRAP_H +#define UIM_QT_INIT_WRAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +int uim_wrap_uim_init(void); +void uim_wrap_uim_quit(void); +void uim_wrap_force_uim_quit(void); + +#ifdef __cplusplus +} +#endif + +#endif Index: toolbar-applet-kde.cpp =================================================================== --- toolbar-applet-kde.cpp (revision 5483) +++ toolbar-applet-kde.cpp (working copy) @@ -45,6 +45,7 @@ #include "uim.h" #include "qtgettext.h" +#include "init-wrap.h" extern "C" { @@ -62,7 +63,8 @@ QWidget *parent, const char *name) : KPanelApplet(configFile, type, actions, parent, name) { - uim_init(); + // Use uim_wrap_uim_init() since kicker may have IM contexts of uim. + uim_wrap_uim_init(); setBackgroundMode(QWidget::X11ParentRelative); toolbar = new UimToolbar(this); toolbar->resize(QSize(toolbar->preferedWidthForHeight(), size().height())); @@ -74,8 +76,8 @@ UimApplet::~UimApplet() { delete toolbar; - // Don't call uim_quit() since kicker may have IM contexts of uim. - // uim_quit(); + // Use uim_wrap_uim_quit() since kicker may have IM contexts of uim. + uim_wrap_uim_quit(); } int UimApplet::widthForHeight(int /* h */) const Index: Makefile.am =================================================================== --- Makefile.am (revision 5483) +++ Makefile.am (working copy) @@ -28,6 +28,9 @@ toolbar-applet-kde.h endif +HEADER_FILES += \ + init-wrap.h + MOC_FILES = \ toolbar-common-quimhelpertoolbar.moc \ toolbar-common-uimstateindicator.moc \ @@ -67,6 +70,10 @@ libexec_PROGRAMS = uim-candwin-qt +noinst_LTLIBRARIES = libuim-init-wrap.la +libuim_init_wrap_la_SOURCES = init-wrap.c +libuim_init_wrap_la_CPPFLAGS = -I$(top_srcdir) + if APPLET_KDE applet_LTLIBRARIES = uim_panelapplet.la appletdir = @KDE_LIB_DIR@/kde3 @@ -105,7 +112,8 @@ immodule-subwindow.cpp immodule-subwindow.h libquiminputcontextplugin_la_CXXFLAGS = $(QT_CXXFLAGS) @X_CFLAGS@ libquiminputcontextplugin_la_LDFLAGS = $(QT_LDFLAGS) -avoid-version -libquiminputcontextplugin_la_LIBADD = $(top_builddir)/uim/libuim-scm.la \ +libquiminputcontextplugin_la_LIBADD = libuim-init-wrap.la \ + $(top_builddir)/uim/libuim-scm.la \ $(top_builddir)/uim/libuim.la if LIBUIM_X_UTIL libquiminputcontextplugin_la_LIBADD += $(top_builddir)/uim/libuim-x-util.la @@ -120,7 +128,7 @@ endif # Toolbar Common -noinst_LTLIBRARIES = libtoolbarcommon.la +noinst_LTLIBRARIES += libtoolbarcommon.la libtoolbarcommon_la_SOURCES = toolbar-common-quimhelpertoolbar.cpp toolbar-common-uimstateindicator.cpp qtgettext.h \ toolbar-common-quimhelpertoolbar.h toolbar-common-uimstateindicator.h libtoolbarcommon_la_CXXFLAGS = $(QT_CXXFLAGS) @@ -145,7 +153,8 @@ toolbar-common-quimhelpertoolbar.h toolbar-common-uimstateindicator.h uim_panelapplet_la_CXXFLAGS = -I@KDE_INCLUDE_DIR@ $(QT_CXXFLAGS) uim_panelapplet_la_LDFLAGS = -avoid-version -module -no-undefined -Wl,--no-undefined -Wl,--allow-shlib-undefined -L@KDE_LIB_DIR@ $(QT_LDFLAGS) -uim_panelapplet_la_LIBADD = $(top_builddir)/uim/libuim-scm.la \ +uim_panelapplet_la_LIBADD = libuim-init-wrap.la \ + $(top_builddir)/uim/libuim-scm.la \ $(top_builddir)/uim/libuim.la \ libtoolbarcommon.la -lkdeui -lkdecore toolbar-applet-kde.cpp: toolbar-applet-kde.moc @@ -182,7 +191,8 @@ uim_pref_qt_CXXFLAGS = $(QT_CXXFLAGS) uim_pref_qt_LDFLAGS = $(QT_LDFLAGS) -uim_pref_qt_LDADD = $(top_builddir)/uim/libuim-custom.la \ +uim_pref_qt_LDADD = libuim-init-wrap.la \ + $(top_builddir)/uim/libuim-custom.la \ $(top_builddir)/uim/libuim-scm.la \ $(top_builddir)/uim/libuim.la