7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75

Reviewed-by: art, ant
This commit is contained in:
Oleg Pekhovskiy 2012-06-26 16:46:00 +04:00
parent 9e9ac093ae
commit 9931c2f2b8
6 changed files with 85 additions and 20 deletions

@ -1474,9 +1474,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
::GetClientRect( GetHWnd(), &r ); ::GetClientRect( GetHWnd(), &r );
mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top); mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top);
//mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam)); //mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam));
if (ImmGetContext() != NULL) {
SetCompositionWindow(r); SetCompositionWindow(r);
}
break; break;
} }
case WM_SIZING: case WM_SIZING:
@ -1535,7 +1533,10 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
// When the window is deactivated, send WM_IME_ENDCOMPOSITION // When the window is deactivated, send WM_IME_ENDCOMPOSITION
// message to deactivate the composition window so that // message to deactivate the composition window so that
// it won't receive keyboard input focus. // it won't receive keyboard input focus.
if (ImmGetContext() != NULL) { HIMC hIMC;
HWND hwnd = ImmGetHWnd();
if ((hIMC = ImmGetContext(hwnd)) != NULL) {
ImmReleaseContext(hwnd, hIMC);
DefWindowProc(WM_IME_ENDCOMPOSITION, 0, 0); DefWindowProc(WM_IME_ENDCOMPOSITION, 0, 0);
} }
} }
@ -1718,11 +1719,9 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
case WM_IME_SETCONTEXT: case WM_IME_SETCONTEXT:
// lParam is passed as pointer and it can be modified. // lParam is passed as pointer and it can be modified.
mr = WmImeSetContext(static_cast<BOOL>(wParam), &lParam); mr = WmImeSetContext(static_cast<BOOL>(wParam), &lParam);
CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
break; break;
case WM_IME_NOTIFY: case WM_IME_NOTIFY:
mr = WmImeNotify(wParam, lParam); mr = WmImeNotify(wParam, lParam);
CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
break; break;
case WM_IME_STARTCOMPOSITION: case WM_IME_STARTCOMPOSITION:
mr = WmImeStartComposition(); mr = WmImeStartComposition();
@ -3723,12 +3722,14 @@ MsgRouting AwtComponent::WmPaste()
// support IME Composition messages // support IME Composition messages
void AwtComponent::SetCompositionWindow(RECT& r) void AwtComponent::SetCompositionWindow(RECT& r)
{ {
HIMC hIMC = ImmGetContext(); HWND hwnd = ImmGetHWnd();
HIMC hIMC = ImmGetContext(hwnd);
if (hIMC == NULL) { if (hIMC == NULL) {
return; return;
} }
COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}}; COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
ImmSetCompositionWindow(hIMC, &cf); ImmSetCompositionWindow(hIMC, &cf);
ImmReleaseContext(hwnd, hIMC);
} }
void AwtComponent::OpenCandidateWindow(int x, int y) void AwtComponent::OpenCandidateWindow(int x, int y)
@ -3742,16 +3743,16 @@ void AwtComponent::OpenCandidateWindow(int x, int y)
SetCandidateWindow(iCandType, x-rc.left, y-rc.top); SetCandidateWindow(iCandType, x-rc.left, y-rc.top);
} }
if (m_bitsCandType != 0) { if (m_bitsCandType != 0) {
HWND proxy = GetProxyFocusOwner();
// REMIND: is there any chance GetProxyFocusOwner() returns NULL here? // REMIND: is there any chance GetProxyFocusOwner() returns NULL here?
::DefWindowProc((proxy != NULL) ? proxy : GetHWnd(), ::DefWindowProc(ImmGetHWnd(),
WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType); WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType);
} }
} }
void AwtComponent::SetCandidateWindow(int iCandType, int x, int y) void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
{ {
HIMC hIMC = ImmGetContext(); HWND hwnd = ImmGetHWnd();
HIMC hIMC = ImmGetContext(hwnd);
CANDIDATEFORM cf; CANDIDATEFORM cf;
cf.dwIndex = iCandType; cf.dwIndex = iCandType;
cf.dwStyle = CFS_CANDIDATEPOS; cf.dwStyle = CFS_CANDIDATEPOS;
@ -3759,17 +3760,20 @@ void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
cf.ptCurrentPos.y = y; cf.ptCurrentPos.y = y;
ImmSetCandidateWindow(hIMC, &cf); ImmSetCandidateWindow(hIMC, &cf);
ImmReleaseContext(hwnd, hIMC);
} }
MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam) MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
{ {
// If the Windows input context is disabled, do not let Windows // If the Windows input context is disabled, do not let Windows
// display any UIs. // display any UIs.
HIMC hIMC = ImmGetContext(); HWND hwnd = ImmGetHWnd();
HIMC hIMC = ImmGetContext(hwnd);
if (hIMC == NULL) { if (hIMC == NULL) {
*lplParam = 0; *lplParam = 0;
return mrDoDefault; return mrDoDefault;
} }
ImmReleaseContext(hwnd, hIMC);
if (fSet) { if (fSet) {
LPARAM lParam = *lplParam; LPARAM lParam = *lplParam;
@ -3824,11 +3828,13 @@ MsgRouting AwtComponent::WmImeComposition(WORD wChar, LPARAM flags)
AwtInputTextInfor* textInfor = NULL; AwtInputTextInfor* textInfor = NULL;
try { try {
HIMC hIMC = ImmGetContext(); HWND hwnd = ImmGetHWnd();
HIMC hIMC = ImmGetContext(hwnd);
DASSERT(hIMC!=0); DASSERT(hIMC!=0);
textInfor = new AwtInputTextInfor; textInfor = new AwtInputTextInfor;
textInfor->GetContextData(hIMC, flags); textInfor->GetContextData(hIMC, flags);
ImmReleaseContext(hwnd, hIMC);
jstring jtextString = textInfor->GetText(); jstring jtextString = textInfor->GetText();
/* The conditions to send the input method event to AWT EDT are: /* The conditions to send the input method event to AWT EDT are:
@ -4012,16 +4018,15 @@ void AwtComponent::InquireCandidatePosition()
DASSERT(!safe_ExceptionOccurred(env)); DASSERT(!safe_ExceptionOccurred(env));
} }
HIMC AwtComponent::ImmGetContext() HWND AwtComponent::ImmGetHWnd()
{ {
HWND proxy = GetProxyFocusOwner(); HWND proxy = GetProxyFocusOwner();
return ::ImmGetContext((proxy != NULL) ? proxy : GetHWnd()); return (proxy != NULL) ? proxy : GetHWnd();
} }
HIMC AwtComponent::ImmAssociateContext(HIMC himc) HIMC AwtComponent::ImmAssociateContext(HIMC himc)
{ {
HWND proxy = GetProxyFocusOwner(); return ::ImmAssociateContext(ImmGetHWnd(), himc);
return ::ImmAssociateContext((proxy != NULL) ? proxy : GetHWnd(), himc);
} }
HWND AwtComponent::GetProxyFocusOwner() HWND AwtComponent::GetProxyFocusOwner()

@ -464,7 +464,7 @@ public:
int caretPos, int visiblePos); int caretPos, int visiblePos);
void InquireCandidatePosition(); void InquireCandidatePosition();
INLINE LPARAM GetCandidateType() { return m_bitsCandType; } INLINE LPARAM GetCandidateType() { return m_bitsCandType; }
HIMC ImmGetContext(); HWND ImmGetHWnd();
HIMC ImmAssociateContext(HIMC himc); HIMC ImmAssociateContext(HIMC himc);
HWND GetProxyFocusOwner(); HWND GetProxyFocusOwner();

@ -156,6 +156,7 @@ FileDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
HIMC hIMC = ::ImmGetContext(hdlg); HIMC hIMC = ::ImmGetContext(hdlg);
if (hIMC != NULL) { if (hIMC != NULL) {
::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0); ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
::ImmReleaseContext(hdlg, hIMC);
} }
WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(parent, NativeDialogWndProcProp)); WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(parent, NativeDialogWndProcProp));

@ -319,8 +319,6 @@ LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, Ms
case WM_IME_STARTCOMPOSITION: case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION: case WM_IME_ENDCOMPOSITION:
case WM_IME_COMPOSITION: case WM_IME_COMPOSITION:
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL: case WM_IME_CONTROL:
case WM_IME_COMPOSITIONFULL: case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT: case WM_IME_SELECT:

@ -336,7 +336,8 @@ AwtTextComponent::WmPaste()
//im --- override to over the spot composition //im --- override to over the spot composition
void AwtTextComponent::SetCompositionWindow(RECT& rc) void AwtTextComponent::SetCompositionWindow(RECT& rc)
{ {
HIMC hIMC = ImmGetContext(); HWND hwnd = ImmGetHWnd();
HIMC hIMC = ImmGetContext(hwnd);
// rc is not used for text component. // rc is not used for text component.
COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} }; COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} };
GetCaretPos(&(cf.ptCurrentPos)); GetCaretPos(&(cf.ptCurrentPos));
@ -348,6 +349,7 @@ void AwtTextComponent::SetCompositionWindow(RECT& rc)
LOGFONT lf; LOGFONT lf;
GetObject(m_hFont, sizeof(LOGFONT), &lf); GetObject(m_hFont, sizeof(LOGFONT), &lf);
ImmSetCompositionFont(hIMC, &lf); ImmSetCompositionFont(hIMC, &lf);
ImmReleaseContext(hwnd, hIMC);
} }
//im --- end //im --- end

@ -0,0 +1,59 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7024749
* @summary JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
* @library ../../../regtesthelpers
* @build Util
* @author Oleg Pekhovskiy: area=awt.toplevel
@run main bug7024749
*/
import java.awt.*;
import test.java.awt.regtesthelpers.Util;
public class bug7024749 {
public static void main(String[] args) {
final Frame f = new Frame("F");
f.setBounds(0,0,200,200);
f.setEnabled(false); // <- disable the top-level
f.setVisible(true);
Window w = new Window(f);
w.setBounds(300,300,300,300);
w.add(new TextField(20));
w.setVisible(true);
Robot robot = Util.createRobot();
robot.setAutoDelay(1000);
Util.waitForIdle(robot);
robot.delay(1000);
Util.clickOnTitle(f, robot);
Util.waitForIdle(robot);
f.dispose();
System.out.println("Test passed!");
}
}