Commit 266c1101 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

imm32: Exit on invalid window in ImmAssociateContext.

parent 80ac0b9a
...@@ -583,12 +583,13 @@ BOOL WINAPI ImmSetActiveContext(HWND hwnd, HIMC himc, BOOL activate) ...@@ -583,12 +583,13 @@ BOOL WINAPI ImmSetActiveContext(HWND hwnd, HIMC himc, BOOL activate)
*/ */
HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
{ {
HIMC old = NULL;
InputContextData *data = get_imc_data(hIMC); InputContextData *data = get_imc_data(hIMC);
HIMC defaultContext;
HIMC old;
TRACE("(%p, %p):\n", hWnd, hIMC); TRACE("(%p, %p):\n", hWnd, hIMC);
if(hIMC && !data) if (!IsWindow(hWnd) || (hIMC && !data))
return NULL; return NULL;
/* /*
...@@ -600,11 +601,8 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) ...@@ -600,11 +601,8 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC)) if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC))
return NULL; return NULL;
if (hWnd) defaultContext = get_default_context( hWnd );
{ old = RemovePropW(hWnd, szwWineIMCProperty);
HIMC defaultContext = get_default_context( hWnd );
old = RemovePropW(hWnd,szwWineIMCProperty);
if (old == NULL) if (old == NULL)
old = defaultContext; old = defaultContext;
else if (old == (HIMC)-1) else if (old == (HIMC)-1)
...@@ -613,9 +611,9 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) ...@@ -613,9 +611,9 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
if (hIMC != defaultContext) if (hIMC != defaultContext)
{ {
if (hIMC == NULL) /* Meaning disable imm for that window*/ if (hIMC == NULL) /* Meaning disable imm for that window*/
SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1); SetPropW(hWnd, szwWineIMCProperty, (HANDLE)-1);
else else
SetPropW(hWnd,szwWineIMCProperty,hIMC); SetPropW(hWnd, szwWineIMCProperty, hIMC);
} }
if (old) if (old)
...@@ -624,7 +622,6 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) ...@@ -624,7 +622,6 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
if (old_data->IMC.hWnd == hWnd) if (old_data->IMC.hWnd == hWnd)
old_data->IMC.hWnd = NULL; old_data->IMC.hWnd = NULL;
} }
}
if (!hIMC) if (!hIMC)
return old; return old;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment