harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chunrong Lai (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
Date Thu, 01 Nov 2007 18:23:50 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-4963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539432
] 

Chunrong Lai commented on HARMONY-4963:
---------------------------------------


  The patch may be not final but it fixes some hang up. 
  According to the original code segment in Harmony, IMManager.getLastActiveIMC().getClient().getInputMethodRequests()
can be called from different places. Since the getInputMethodRequests() can be overridden
to create/modify components, it is just very difficult for a programmer to write the thread-safe
program.
  My patch assumes a simpler getInputMethodRequests() which has thread safety if it has been
initialized even when it is overriden. 
  Anyway I welcome the discussion and feedback on this issue.

> [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests()
is overridden
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4963
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Win32
>            Reporter: Chunrong Lai
>            Assignee: Alexei Zakharov
>         Attachments: H4963.1.patch
>
>
>  In debugging of a hangup of some application I see below functions in Harmony:
>  modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:
>     public void activate() {
>         WinEventQueue.Task task = new WinEventQueue.Task() {
>             @Override
>             public void perform() {
>                 final long hwnd = win32.GetFocus();
>                 if (hwnd == 0l) return;
>                 long curIMC = win32.ImmGetContext(hwnd);
>                 if ((curIMC != 0) && isActiveClient()) {
>                     win32.ImmSetOpenStatus(curIMC, 0);
>                 }
>                 if (curIMC != hIMC) {                    
>                     long res = win32.ImmAssociateContext(hwnd, hIMC);
>                     ......
>                 } else {
>                     ......
>                 }
>                 win32.ImmReleaseContext(hwnd, curIMC);
>             }
>         };
>         wwf.eventQueue.performTask(task);
>         .....
>     }    
>     private static boolean isActiveClient() {
>         InputMethodContext imc = IMManager.getLastActiveIMC();
>         if ((imc == null) || (imc.getClient() == null)) {
>             return false;
>         }
>         return (imc.getClient().getInputMethodRequests() != null);
>     }
>  In my understanding the imc.getClient().getInputMethodRequests(), executed in final
WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by
sub-components.
>  The fix can be in several shapes:
>   (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
>   (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example,
if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests()
in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it
will be thread-safe in winIM.activate(). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message