imm32: ImmGetCandidateWindow should not return unset data.

This commit is contained in:
Aric Stewart 2013-10-01 14:30:12 -05:00 committed by Alexandre Julliard
parent 020456628c
commit bd9e608133
2 changed files with 25 additions and 0 deletions

View File

@ -636,6 +636,7 @@ HIMC WINAPI ImmCreateContext(void)
InputContextData *new_context;
LPGUIDELINE gl;
LPCANDIDATEINFO ci;
int i;
new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData));
@ -663,6 +664,9 @@ HIMC WINAPI ImmCreateContext(void)
gl->dwSize = sizeof(GUIDELINE);
ImmUnlockIMCC(new_context->IMC.hGuideLine);
for (i = 0; i < sizeof(new_context->IMC.cfCandForm) / sizeof(CANDIDATEFORM); i++)
new_context->IMC.cfCandForm[i].dwIndex = ~0u;
/* Initialize the IME Private */
new_context->IMC.hPrivate = ImmCreateIMCC(new_context->immKbd->imeInfo.dwPrivateDataSize);
@ -1035,6 +1039,9 @@ BOOL WINAPI ImmGetCandidateWindow(
if ( dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) )
return FALSE;
if (data->IMC.cfCandForm[dwIndex].dwIndex != dwIndex)
return FALSE;
*lpCandidate = data->IMC.cfCandForm[dwIndex];
return TRUE;

View File

@ -465,6 +465,7 @@ static void test_ImmThreads(void)
BOOL rc;
LOGFONT lf;
COMPOSITIONFORM cf;
CANDIDATEFORM cdf;
DWORD status, sentence;
POINT pt;
@ -552,6 +553,23 @@ static void test_ImmThreads(void)
rc = ImmGetStatusWindowPos(otherHimc, &pt);
ok(rc != 0 || broken(rc == 0), "ImmGetStatusWindowPos failed\n");
/* Candidate Window */
rc = ImmGetCandidateWindow(himc, 0, &cdf);
ok (rc == 0, "ImmGetCandidateWindow should fail\n");
cdf.dwIndex = 0;
cdf.dwStyle = CFS_CANDIDATEPOS;
cdf.ptCurrentPos.x = 0;
cdf.ptCurrentPos.y = 0;
rc = ImmSetCandidateWindow(himc, &cdf);
ok (rc == 1, "ImmSetCandidateWindow should succeed\n");
rc = ImmGetCandidateWindow(himc, 0, &cdf);
ok (rc == 1, "ImmGetCandidateWindow should succeed\n");
rc = ImmGetCandidateWindow(otherHimc, 0, &cdf);
todo_wine ok (rc == 0, "ImmGetCandidateWindow should fail\n");
rc = ImmSetCandidateWindow(otherHimc, &cdf);
todo_wine ok (rc == 0, "ImmSetCandidateWindow should fail\n");
ImmReleaseContext(threadinfo.hwnd,otherHimc);
ImmReleaseContext(hwnd,himc);