Index: gtk/gtktextview.c
===================================================================
--- gtk/gtktextview.c	(リビジョン 22080)
+++ gtk/gtktextview.c	(作業コピー)
@@ -2045,7 +2045,8 @@
    */
   area.width = 0;
 
-  gtk_im_context_set_cursor_location (text_view->im_context, &area);
+  if (GTK_WIDGET_REALIZED (text_view))
+    gtk_im_context_set_cursor_location (text_view->im_context, &area);
 }
 
 static gboolean
@@ -3787,6 +3788,9 @@
       
       tmp_list = tmp_list->next;
     }
+
+  /* Ensure updating the spot location. */
+  gtk_text_view_update_im_spot_location(text_view);
 }
 
 static void
Index: gtk/gtkimmodule.c
===================================================================
--- gtk/gtkimmodule.c	(リビジョン 22080)
+++ gtk/gtkimmodule.c	(作業コピー)
@@ -671,6 +671,9 @@
   GdkScreen *screen;
   GtkSettings *settings;
       
+  /* assertion to make sure all of the unexpected invocation is really gone. */
+  g_return_val_if_fail (client_window != NULL, SIMPLE_ID);
+
   if (!contexts_hash)
     gtk_im_module_initialize ();
 
@@ -682,7 +685,7 @@
 
   /* Check if the certain immodule is set in XSETTINGS.
    */
-  if (client_window != NULL && GDK_IS_DRAWABLE (client_window))
+  if (GDK_IS_DRAWABLE (client_window))
     {
       screen = gdk_drawable_get_screen (GDK_DRAWABLE (client_window));
       if (screen)
