diff -pruN 0.4.16-2/debian/changelog 0.4.16-2ubuntu5/debian/changelog
--- 0.4.16-2/debian/changelog	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/changelog	2011-09-22 16:15:53.000000000 +0000
@@ -1,3 +1,42 @@
+scim-bridge (0.4.16-2ubuntu5) oneiric; urgency=low
+
+  * debian/{rules,scim-bridge-client-gtk.install}: Use GTK+ multiarch
+    lib path. Fixes FTBFS. (LP: #832786) (Closes: #640625)
+
+ -- Daniel T Chen <crimsun@ubuntu.com>  Thu, 22 Sep 2011 07:35:29 -0400
+
+scim-bridge (0.4.16-2ubuntu4) maverick; urgency=low
+
+  * add some information to the README about crashes induced apparently by
+    incompatible data structures in old config files. (LP: #338217)
+
+ -- Rolf Leggewie <foss@rolf.leggewie.biz>  Sun, 21 Feb 2010 22:28:50 +0100
+
+scim-bridge (0.4.16-2ubuntu3) karmic; urgency=low
+
+  * add scim-bridge-client-qt4 to Recommends (LP: #400049)
+  * fix some minor spelling mistakes in the control file
+
+ -- Rolf Leggewie <foss@rolf.leggewie.biz>  Thu, 16 Jul 2009 04:34:27 +0200
+
+scim-bridge (0.4.16-2ubuntu2) karmic; urgency=low
+
+  * debian/im-switch/scim-bridge: fixed search path of Qt immodule to work
+    with Qt 4. (LP: #305452)
+
+ -- Ikuya Awashiro <ikuya@fruitsbasket.info>  Wed, 01 Jul 2009 13:45:05 +0000
+
+scim-bridge (0.4.16-2ubuntu1) karmic; urgency=low
+
+  * Resynchronise with Debian. Remaining changes:
+    - 50_check_scim_binary.dpatch: Fix 10-20s delay in launching apps when
+      scim is not running.
+    - 50_fix_qt4_focus.dpatch: Fix focus loss under KDE 4.
+    - 51_quiet.dpatch: Turn some error messages into debug lines.
+    - Just have scim-bridge-agent depend on scim, not scim | skim.
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Thu, 25 Jun 2009 22:02:52 +0100
+
 scim-bridge (0.4.16-2) unstable; urgency=low
 
   * Fix FTBFS by add proper parameter to chrpath. (Closes: #529571)
@@ -14,6 +53,51 @@ scim-bridge (0.4.16-1) unstable; urgency
 
  -- Zhengpeng Hou <zhengpeng-hou@ubuntu.com>  Sat, 25 Apr 2009 15:22:36 +0000
 
+scim-bridge (0.4.14-2ubuntu5) intrepid; urgency=low
+
+  * 50_check_scim_binary.dpatch: Enable again, since the Qt agent really
+    does get upset if scim is installed but not running (as is the case in
+    many locales). This time, check for whether the scim-helper-manager
+    process is running.
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Sun, 26 Oct 2008 16:07:56 +0000
+
+scim-bridge (0.4.14-2ubuntu4) intrepid; urgency=low
+
+  All changes thanks to Zheng Peng-Hou.
+  * Disable 50_check_scim_binary.dpatch since only a dependency on scim is
+    enough. Actually only a running scim-helper is needed, which is in the
+    scim package and gets started (and restarted if it dies) automatically.
+    However, modified the patch to check for schim-helper instead in case the
+    patch becomes necessary again. (LP: #286923)
+  * Add patch 50_fix_qt4_focus.dpatch to fix focus loss under KDE4. (LP:
+    #250046) 
+  * Update debian/control to fix dependencies and the Name of the Original
+    Maintainer.
+
+ -- Arne Goetje <arne@ubuntu.com>  Wed, 22 Oct 2008 10:44:39 +0800
+
+scim-bridge (0.4.14-2ubuntu3) intrepid; urgency=low
+
+  * Update 50_check_scim_binary.dpatch to check for running scim
+
+ -- Jonathan Riddell <jriddell@ubuntu.com>  Mon, 20 Oct 2008 10:38:48 +0100
+
+scim-bridge (0.4.14-2ubuntu2) intrepid; urgency=low
+
+  * Add 51_quiet.dpatch, turns some error into debug lines, stop it
+    outputting lots of unnecessary text.
+
+ -- Jonathan Riddell <jriddell@ubuntu.com>  Fri, 19 Sep 2008 13:37:03 +0100
+
+scim-bridge (0.4.14-2ubuntu1) intrepid; urgency=low
+
+  * Fixes 10-20s delay in launching apps when scim-bridge-client(s) installed
+    but scim is not
+    - 50_check_scim_binary.dpatch (LP: 203334)
+
+ -- Roderick B. Greening <roderick.greening@gmail.com>  Mon, 15 Sep 2008 17:15:29 -0230
+
 scim-bridge (0.4.14-2) unstable; urgency=low
 
   * Merged with 0.4.14-1ubuntu2, which in particular fixes a dangling
diff -pruN 0.4.16-2/debian/control 0.4.16-2ubuntu5/debian/control
--- 0.4.16-2/debian/control	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/control	2011-09-22 16:15:53.000000000 +0000
@@ -1,7 +1,8 @@
 Source: scim-bridge
 Section: utils
 Priority: optional
-Maintainer: Zhengpeng Hou <zhengpeng-hou@ubuntu.com>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Zhengpeng Hou <zhengpeng-hou@ubuntu.com>
 Uploaders: Anthony Fok <foka@debian.org>
 Build-Depends: debhelper (>= 7.0), autotools-dev, libgtk2.0-dev (>= 2.10.1), libscim-dev (>= 1.4.6), dpatch, libqt3-mt-dev (>= 3.3.6), libqt4-dev, chrpath
 Standards-Version: 3.8.1
@@ -9,16 +10,16 @@ Homepage: http://www.scim-im.org
 
 Package: scim-bridge-agent
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, scim-modules-socket, scim | skim 
-Recommends: scim-bridge-client-gtk | scim-bridge-client-qt
+Depends: ${shlibs:Depends}, ${misc:Depends}, scim-modules-socket, scim
+Recommends: scim-bridge-client-gtk | scim-bridge-client-qt | scim-bridge-client-qt4
 Description: IME server of scim-bridge communicate with SCIM
- scim-bridge is a wrapper library for SCIM, writen in C.
+ scim-bridge is a wrapper library for SCIM, written in C.
  .
  SCIM (Smart Common Input Method) is an input method (IM) platform.
  .
  Scim-bridge has two parts: agent and client. scim-bridge-agent stands
  between SCIM and the clients (IMModules), so the clients only need 
- communicate with scim-bridge-agent, because scim-bridge-agent was writen
+ communicate with scim-bridge-agent, because scim-bridge-agent was written
  in C, it will solve some C++ ABI problems.
 
 Package: scim-bridge-client-gtk
@@ -26,31 +27,31 @@ Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, scim-bridge-agent
 Replaces: scim-bridge (= 0.2.4-1)
 Description: IME server of scim-bridge communicate with SCIM
- scim-bridge is a wrapper libray for SCIM, writen in C.
+ scim-bridge is a wrapper libray for SCIM, written in C.
  .
  SCIM (Smart Common Input Method) is an input method (IM) platform.
  .
- Scim-bridge-client-gtk is the gtk client of scim-bridge, it provide
+ Scim-bridge-client-gtk is the gtk client of scim-bridge, it provides
  another gtk-immodule for SCIM.
 
 Package: scim-bridge-client-qt
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, scim-bridge-agent
 Description: IME server of scim-bridge communicate with SCIM
- scim-bridge is a wrapper library for SCIM, writen in C.
+ scim-bridge is a wrapper library for SCIM, written in C.
  .
  SCIM (Smart Common Input Method) is an input method (IM) platform.
  .
- Scim-bridge-client-qt is the qt client of scim-bridge, it provide
+ Scim-bridge-client-qt is the qt client of scim-bridge, it provides
  another qt-immodule for SCIM.
 
 Package: scim-bridge-client-qt4
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, scim-bridge-agent
 Description: IME server of scim-bridge communicate with SCIM
- scim-bridge is a wrapper library for SCIM, writen in C.
+ scim-bridge is a wrapper library for SCIM, written in C.
  .
  SCIM (Smart Common Input Method) is an input method (IM) platform.
  .
- Scim-bridge-client-qt4 is the qt4 client of scim-bridge, it provide
+ Scim-bridge-client-qt4 is the qt4 client of scim-bridge, it provides
  another qt-immodule for SCIM.
diff -pruN 0.4.16-2/debian/im-switch/scim-bridge 0.4.16-2ubuntu5/debian/im-switch/scim-bridge
--- 0.4.16-2/debian/im-switch/scim-bridge	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/im-switch/scim-bridge	2011-09-22 16:15:53.000000000 +0000
@@ -10,7 +10,9 @@ if [ -e /usr/lib/gtk-2.0/*/immodules/im-
 else
     GTK_IM_MODULE=xim
 fi
-if [ -e /usr/lib/qt3/plugins/inputmethods/im-scim-bridge.so ]; then
+if [ -e /usr/lib/qt4/plugins/inputmethods/im-scim-bridge.so ]; then
+    QT_IM_MODULE=scim-bridge
+elif [ -e /usr/lib/qt3/plugins/inputmethods/im-scim-bridge.so ]; then
     QT_IM_MODULE=scim-bridge
 else
     QT_IM_MODULE=xim
diff -pruN 0.4.16-2/debian/patches/00list 0.4.16-2ubuntu5/debian/patches/00list
--- 0.4.16-2/debian/patches/00list	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/patches/00list	2011-09-22 16:15:53.000000000 +0000
@@ -3,3 +3,6 @@
 30_correct_moc.dpatch
 40_correct_gtk_client_missing_include.dpatch
 50_fix_FTBFS_with_gcc44.dpatch
+50_check_scim_binary.dpatch
+50_fix_qt4_focus.dpatch
+51_quiet.dpatch
diff -pruN 0.4.16-2/debian/patches/50_check_scim_binary.dpatch 0.4.16-2ubuntu5/debian/patches/50_check_scim_binary.dpatch
--- 0.4.16-2/debian/patches/50_check_scim_binary.dpatch	1970-01-01 00:00:00.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/patches/50_check_scim_binary.dpatch	2011-09-22 16:15:53.000000000 +0000
@@ -0,0 +1,25 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50_check_scim_binary.dpatch by <roderick.greening@gmail.com>,
+## Zhengpeng Hou <zhengpeng-hou@ubuntu.com>, Arne Goetje <arne@ubuntu.com>,
+## and Colin Watson <cjwatson@ubuntu.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fixes 10-20s delay in launching apps when scim-bridge-client(s) installed but scim is not running
+
+@DPATCH@
+diff -urNad scim-bridge-0.4.16-2ubuntu1~/client-common/scim-bridge-client.c scim-bridge-0.4.16-2ubuntu1/client-common/scim-bridge-client.c
+--- scim-bridge-0.4.16-2ubuntu1~/client-common/scim-bridge-client.c	2009-06-25 21:54:26.000000000 +0100
++++ scim-bridge-0.4.16-2ubuntu1/client-common/scim-bridge-client.c	2009-06-25 21:54:36.000000000 +0100
+@@ -1039,6 +1039,12 @@
+         return RETVAL_FAILED;
+     }
+ 
++    /* This is a quick fix. "pidof scim-helper-manager >/dev/null" should probably be defined somewhere instead of coded like below - RG */
++    if (system ("pidof scim-helper-manager >/dev/null") != 0) {
++        scim_bridge_pdebugln (8, "There is no scim-helper-manager binary running");
++        return RETVAL_FAILED;
++    }
++
+     int i;
+     for (i = 0; i < 10; ++i) {
+         int socket_fd = socket (PF_UNIX, SOCK_STREAM, 0);
diff -pruN 0.4.16-2/debian/patches/50_fix_qt4_focus.dpatch 0.4.16-2ubuntu5/debian/patches/50_fix_qt4_focus.dpatch
--- 0.4.16-2/debian/patches/50_fix_qt4_focus.dpatch	1970-01-01 00:00:00.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/patches/50_fix_qt4_focus.dpatch	2011-09-22 16:15:53.000000000 +0000
@@ -0,0 +1,38 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50_fix_qt4_focus.dpatch by Hou ZhengPeng <zhengpeng.hou@gmail.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix immodule install dir
+
+@DPATCH@
+
+diff -ruNad scim-bridge-0.4.15/client-qt/scim-bridge-client-imcontext-qt.cpp scim-bridge-0.4.15-work/client-qt/scim-bridge-client-imcontext-qt.cpp
+--- scim-bridge-0.4.15/client-qt/scim-bridge-client-imcontext-qt.cpp	2007-07-07 02:30:10.000000000 +0000
++++ scim-bridge-0.4.15-work/client-qt/scim-bridge-client-imcontext-qt.cpp	2008-09-24 13:32:45.000000000 +0000
+@@ -220,7 +220,12 @@
+ {
+     scim_bridge_pdebugln (4, "ScimBridgeClientIMContextImpl::setFocusWidget ()");
+     QInputContext::setFocusWidget (widget);
+-    focus_in ();
++	if (widget == NULL) {
++    	focus_out ();
++	}
++	else {
++    	focus_in ();
++	}
+     update ();
+ }
+ 
+@@ -442,8 +447,10 @@
+         }
+     }
+ 
+-    set_preedit_shown (false);
+-    update_preedit ();
++	if (preedit_shown) {
++    	set_preedit_shown (false);
++    	update_preedit ();
++	}
+ 
+     focused_imcontext = NULL;
+ }
diff -pruN 0.4.16-2/debian/patches/51_quiet.dpatch 0.4.16-2ubuntu5/debian/patches/51_quiet.dpatch
--- 0.4.16-2/debian/patches/51_quiet.dpatch	1970-01-01 00:00:00.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/patches/51_quiet.dpatch	2011-09-22 16:15:53.000000000 +0000
@@ -0,0 +1,28 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 51_quiet.dpatch by Jonathan Riddell
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fixes 10-20s delay in launching apps when scim-bridge-client(s) installed but scim is not
+
+@DPATCH@
+diff -urNad scim-bridge-0.4.14~/client-qt/scim-bridge-client-imcontext-qt.cpp scim-bridge-0.4.14/client-qt/scim-bridge-client-imcontext-qt.cpp
+--- scim-bridge-0.4.14~client-qt/client-qt/scim-bridge-client-imcontext-qt.cpp	2007-07-07 03:30:10.000000000 +0100
++++ scim-bridge-0.4.14client-qt/client-qt/scim-bridge-client-imcontext-qt.cpp	2008-09-19 13:24:48.000000000 +0100
+@@ -173,7 +173,7 @@
+ #endif
+ 
+     if (!scim_bridge_client_is_messenger_opened ()) {
+-        scim_bridge_perrorln ("The messenger is now down");
++        scim_bridge_pdebugln (1, "The messenger is now down");
+     } else if (scim_bridge_client_register_imcontext (this)) {
+         scim_bridge_perrorln ("Failed to register the IMContext");
+     } else {
+@@ -189,7 +189,7 @@
+     if (this == focused_imcontext) focus_out ();
+ 
+     if (!scim_bridge_client_is_messenger_opened ()) {
+-        scim_bridge_perrorln ("The messenger is now down");
++        scim_bridge_pdebugln (1, "The messenger is now down");
+     } else if (scim_bridge_client_deregister_imcontext (this)) {
+         scim_bridge_perrorln ("Failed to deregister an IMContext");
+     } else {
diff -pruN 0.4.16-2/debian/README.Debian 0.4.16-2ubuntu5/debian/README.Debian
--- 0.4.16-2/debian/README.Debian	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/README.Debian	2011-09-22 16:15:53.000000000 +0000
@@ -1,10 +1,10 @@
-If you want to use scim-bridge, I assume that you have installed relate
+If you want to use scim-bridge, I assume that you have installed related
 packages, like scim-bridge-agent, scim-bridge-client-{gtk,qt}. 
 To use it, you shall set your corresponding environment variable, such
 as, GTK_IM_MODULE and QT_IM_MODULE. In most recently Debian/Ubuntu, if
 you have im-switch installed, you can provide a configure file in 
 ~/.xinput.d/<ll_CC>, which contain as below:
-##=================Begain============================================
+##=================Begin============================================
     XIM=SCIM
     if [ -e /usr/bin/skim ]; then
         XIM_PROGRAM=/usr/bin/skim
@@ -20,4 +20,11 @@ You may open a terminal, and do: locale 
 the value of ll_CC. In above configure file, we make GTK and Qt programs all
 use scim-bridge, but you can decide whether to use them both.
 
+It looks like many old-time users of scim and scim-bridge experience frequent
+crashes (cf. https://launchpad.net/bugs/338217).  The reason is not completely
+clear, but seems to stem from incompatible data structures in old config files
+that crash more recent versions of scim-bridge.  The best known remedy is to
+"rm -Rf ~/.scim" (or backup that directory somewhere else if you prefer) and
+optionally reinstall scim and other affected packages.
+
 If you have any problem, you may contact me: zhengpeng-hou AT ubuntu .com.
diff -pruN 0.4.16-2/debian/rules 0.4.16-2ubuntu5/debian/rules
--- 0.4.16-2/debian/rules	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/rules	2011-09-22 16:15:53.000000000 +0000
@@ -8,6 +8,7 @@
 # from having to guess our platform (since we know it already)
 export DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 export DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+export DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
 ONFFLAGS =
 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
@@ -75,8 +76,8 @@ install: build
 	# Add here commands to install the package into debian/scim-bridge.
 	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
 	chrpath -d debian/tmp/usr/bin/scim-bridge
-	rm debian/tmp/usr/lib/gtk-2.0/*/immodules/im-scim-bridge.a
-	rm debian/tmp/usr/lib/gtk-2.0/*/immodules/im-scim-bridge.la
+	rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gtk-2.0/*/immodules/im-scim-bridge.a
+	rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gtk-2.0/*/immodules/im-scim-bridge.la
 	rm debian/tmp/usr/lib/qt3/plugins/inputmethods/im-scim-bridge.a
 	rm debian/tmp/usr/lib/qt3/plugins/inputmethods/im-scim-bridge.la
 	rm debian/tmp/usr/lib/qt4/plugins/inputmethods/im-scim-bridge.a
diff -pruN 0.4.16-2/debian/scim-bridge-client-gtk.install 0.4.16-2ubuntu5/debian/scim-bridge-client-gtk.install
--- 0.4.16-2/debian/scim-bridge-client-gtk.install	2011-09-22 16:15:52.000000000 +0000
+++ 0.4.16-2ubuntu5/debian/scim-bridge-client-gtk.install	2011-09-22 16:15:53.000000000 +0000
@@ -1 +1 @@
-usr/lib/gtk-2.0/*/immodules/im-scim-bridge.so
+usr/lib/*/gtk-2.0/*/immodules/im-scim-bridge.so
