Bug 7532

Summary: Input method toggle causes an infinite loop
Product: UIM Reporter: Jae-hyeon Park <jhyeon>
Component: generic Scheme codesAssignee: uim-bugs
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Jae-hyeon Park 2006-07-15 08:30:35 UTC
If I toggle between "Latin characters" IM and "Anthy,"
gedit enters an infinite loop.


How to reproduce:

(0) Delete ~/.uim.d and ~/.uim

(1) Run uim-pref-gtk as

    $ LANG=en_US.UTF-8 uim-pref-gtk

(2) In "Global settings" group,

    Check "Specify default IM"
    Set "Default input method" to "Latin characters"

    Check "Enable input method toggle by hot keys"
    Set "Alternative input method" to "Anthy"

(3) In "Toobar" group,

    Uncheck all the seven options

(4) Click "Apply"

(5) Run gedit as

    $ LANG=en_US.UTF-8 gedit

(6) Press the IM toggle key ["<Meta>space" by default] to switch to Anthy.
    This causes a backtrace message to be printed.

    Press the IM toggle key again, and an infinite loop.


Tested version: trunk rev. 3742
Comment 1 Etsushi Kato 2006-07-15 11:00:21 UTC
Hmm, I can reproduce this bug with "Enable menu-based input method switcher" off.

ERROR: bad arg to nth (see errobj)

*backtrace*
>>(f (g arg))
>>(context-current-widget-states c)
>>(toggle-state-new (context-primary-im? c) (im-name (context-im c))
(context-current-widget-states c))

It seems context-current-widget-states is not working a context like latin-IM,
 which doesn't have any widget action if menu-based switcher is off.

Could you investigate, YamaKen?
Comment 2 Etsushi Kato 2006-07-15 14:05:17 UTC
Anyway, I've update latin.scm to use widget and action framework in r3743.
Also I've found a problem in latin.scm (always update preedit even
without preedit).  This should be also fixed in the revision.
Comment 3 YamaKen 2006-07-15 20:17:46 UTC
Thanks reporting and fixing. The method for the fix is appropriate. Please
finish it along with the current direction.
Comment 4 Jae-hyeon Park 2006-07-16 14:46:10 UTC
I found another way to cause a crash with revision 3747.  If I change
an option of the alternative IM, gedit crashes printing a backtrace
message.


How to reproduce:

(0) Delete ~/.uim.d and ~/.uim

(1) Run uim-pref-gtk as

    $ LANG=en_US.UTF-8 uim-pref-gtk

(2) In "Global settings" group,

    Check "Specify default IM"
    Set "Default input method" to "Latin characters"

    Check "Enable input method toggle by hot keys"
    Set "Alternative input method" to "Anthy"

(3) In "Toobar" group,

    Uncheck all the seven options

(4) Click "Apply"

(5) Run gedit as

    $ LANG=en_US.UTF-8 gedit

(6) Press the IM toggle key ["<Meta>space" by default] to switch to Anthy.

(7) In "Anthy (advanced)" group,

    Check "Enable input prediction"

(8) Click "Apply"
Comment 5 Etsushi Kato 2006-07-17 06:46:04 UTC
It seems this bug also occurs with direct IM if (2) is changed as follows.

    Uncheck "Specify default IM"

    Check "Enable input method toggle by hot keys"
    Set "Alternative input method" to "Anthy"

It produces backtrace, ERROR: wta to car (errobj action_direct_direct).
Comment 6 Etsushi Kato 2006-07-18 11:19:37 UTC
I got more meaningful backtrace.

ERROR: wta to car (errobj action_anthy_direct)

*backtrace*
>>(car elm)
>>(pred elm)
>>(pred elm)
>>(if (pred elm) (cons elm state) state)
>>(#<CLOSURE (state elms) (if (null? elms) (cons 1 (reverse state))
(let-internal (elm) ((car elms)) (cons () (if (pred elm) (cons elm state)
state))))> (quote ()) (quote (action_anthy_direct)))
>>(widgets-refresh-switcher-widget alt-widgets ctx)
>>(if toggle-state (let-internal (alt-widgets) ((toggle-state-widget-states
toggle-state)) (toggle-state-set-widget-states! toggle-state
(widgets-refresh-switcher-widget alt-widgets ctx))))
>>(let-internal (toggle-state widgets) ((context-toggle-state ctx)
(context-widgets ctx)) (begin (context-set-widgets! ctx
(widgets-refresh-switcher-widget widgets ctx)) (if toggle-state (let-internal
(alt-widgets) ((toggle-state-widget-states toggle-state))
(toggle-state-set-widget-states! toggle-state (widgets-refresh-switcher-widget
alt-widgets ctx)))) (if (context-focused? ctx)
(context-propagate-widget-configuration ctx))))
>>((cdr pair))
>>(custom-reload-user-configs)


And if I changes im-custom.scm, toggle im between latin-IM and Anthy with 
"Enable menu-based input method switcher" #f doesn't seem to cause the problem.
But I'm not sure this is proper fix.

--- im-custom.scm       (revision 3751)
+++ im-custom.scm       (working copy)
@@ -347,7 +347,9 @@
        (require "im-switcher.scm"))
     ;; Since context-list is empty on start-up, imsw-register-widget
     ;; is not called here.
-    (if (symbol-bound? 'context-refresh-switcher-widget!)
+    (if (and
+         (symbol-bound? 'context-refresh-switcher-widget!)
+         toolbar-show-action-based-switcher-button?)
        (for-each context-refresh-switcher-widget!
                  context-list))))


BTW, I found another problem.  

1 Start a application with following setting.

  "Enable menu-based input method switcher" #f 
  "Specify default IM" #t
  "Default input method" Anthy
  "Enable input method toggle by hot keys" #t
  "Alternative input method" Latin characters

2 Run uim-pref and check "Enable menu-based IM switcher" and Apply.

3 Press uim-toolbar's IM icon check available IMs.

4 There in no "Direct" IM in the menu list!

In this test, if I set "Direct" IM to "Alternative input method" in 1.,
toggling IM after 4. cause crash of the application.

YamaKen, could you investigate?
Comment 7 Etsushi Kato 2006-07-19 19:22:39 UTC
The problem in comment #6 seems to be sovled with the following patch.

Index: im-switcher.scm
===================================================================
--- im-switcher.scm     (revision 3759)
+++ im-switcher.scm     (working copy)
@@ -63,6 +63,8 @@
 ;; independent.
 (define imsw-actions
   (lambda ()
+    (if (not (memq 'direct enabled-im-list))
+       (set! enabled-im-list (append enabled-im-list '(direct))))
     (filter-map
      (lambda (idname)
        (let ((im (assq idname im-list)))

I'll commit these changes in im-custom.scm and im-switcher.scm.
YamaKen, if it is not appropriate, please reopen this bug.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.