After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 309054 - Need unregister xim_instantiate_callback at finalize of xim input module
Need unregister xim_instantiate_callback at finalize of xim input module
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Input Methods
2.6.x
Other All
: Normal normal
: ---
Assigned To: Hidetoshi Tajima
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-06-26 13:44 UTC by ek.kato
Modified: 2005-06-30 05:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix at the finalization of the xim context (773 bytes, patch)
2005-06-26 13:45 UTC, ek.kato
none Details | Review
Revised patch (1.00 KB, patch)
2005-06-26 14:54 UTC, ek.kato
none Details | Review

Description ek.kato 2005-06-26 13:44:21 UTC
Please describe the problem:
gtk+ applications crash with following procedure.  See also
https://bugs.freedesktop.org/show_bug.cgi?id=3630 (bug report on uim).
I tested this with gtk+2-2.6.7.

1. Run gtk+ application with GTK_IM_MODULE=xim XMODIFIERS=@im=kinput2 without
running process of kinput2.
2. Then change the input context of gtk+ to any other method from xim.
3. Run kinput2 process from a terminal.
4. Application crashes.

It seems that unregister xim_instantiate_callback is needed at finalization if
context_xim->im_info->reconnecting == TRUE.

Please apply the attached patch to gtkimcontextxim.c.

Cheers,

-- 
Etsushi Kato
ekato@ees.hokudai.ac.jp

Steps to reproduce:



Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 ek.kato 2005-06-26 13:45:27 UTC
Created attachment 48352 [details] [review]
Fix at the finalization of the xim context
Comment 2 ek.kato 2005-06-26 14:53:39 UTC
In addition, I found another bug in relation to XNDestroyCallback.

1. Run application with GTK_IM_MODULE=xim XMODIFIERS=kinput2 with kinput2 running.
2. Change application's gtk im context to other im from xim. 
3. kill kinput2.
4. Application crashes.

In this case xim_destroy_callback is called and causes the crash.  So it is
needed to remove this callback at finalizing xim context.

Again, I created unified patch to fix the problem in addition to former problem.
Please apply.

Cheers,
Comment 3 ek.kato 2005-06-26 14:54:47 UTC
Created attachment 48356 [details] [review]
Revised patch
Comment 4 Matthias Clasen 2005-06-27 02:30:19 UTC
I just unconditionally unregistered the callbacks. 

2005-06-26  Matthias Clasen  <mclasen@redhat.com>

	* modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize): 
	Unregister XIM callbacks here.  (#309054)
Comment 5 ek.kato 2005-06-27 18:05:51 UTC
Thanks for your quick reply.

But removing the condition causes crash if kinput2 is not running.

1. run gedit (GTK_IM_MODULE=xim XMODIFIERS=@im=kinput2) without kinput2 process.
2. change im context to default.
3. gedit crashes.

This is because XSetIMValues() is called without successful XOpenIM().  So
context_xim->im_info->reconnecting == TRUE check is definitely needed.

Cheers,

-- 
Etsushi Kato
ekato@ees.hokudai.ac.jp
Comment 6 Matthias Clasen 2005-06-27 18:43:35 UTC
Should be fixed now. Can you retest ?
Comment 7 ek.kato 2005-06-27 18:56:13 UTC
Tested with revision 1.49.2.3 and confirmed works fine.

Thanks!
Comment 8 ek.kato 2005-06-30 05:01:34 UTC
Hi again,

I've noticed that my patch just consider a application with only one input
context (like leafpad).  This introduced a side effect in removing
destoy_callback in a application with many input context.

For applications with more that one input context, removing destroy callback
while finalizing a selected context causes problem since there still exists
other x input context in the application.  For these applications, destroy
callback is needed to be called in the remained contexts when XIM server
(kinput2) is killed.

Here is the patch that the callbacks will be removed only if ics->next
is NULL (only one input context exists and the context is finalized).

--- gtkimcontextxim.c.orig      Tue Jun 28 17:04:05 2005
+++ gtkimcontextxim.c   Thu Jun 30 11:25:30 2005
@@ -565,7 +565,7 @@

   context_xim->finalizing = TRUE;

-  if (context_xim->im_info)
+  if (context_xim->im_info && !context_xim->im_info->ics->next)
     {
       GdkDisplay *display;