imm32: Do not let ImmDestroyContext destroy any default contexts.

oldstable
Aric Stewart 2015-02-25 11:45:18 -06:00 committed by Alexandre Julliard
parent e28fc1177a
commit f3967902c5
1 changed files with 15 additions and 5 deletions

View File

@ -77,6 +77,7 @@ typedef struct tagInputContextData
ImmHkl *immKbd;
UINT lastVK;
BOOL threadDefault;
DWORD magic;
} InputContextData;
@ -119,6 +120,7 @@ static CRITICAL_SECTION threaddata_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
#define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE)
static BOOL IMM_DestroyContext(HIMC hIMC);
static InputContextData* get_imc_data(HIMC hIMC);
static inline WCHAR *strdupAtoW( const char *str )
{
@ -244,6 +246,16 @@ static IMMThreadData* IMM_GetThreadData(DWORD id)
return data;
}
static BOOL IMM_IsDefaultContext(HIMC imc)
{
InputContextData *data = get_imc_data(imc);
if (!data)
return FALSE;
return data->threadDefault;
}
static void IMM_FreeThreadData(void)
{
IMMThreadData *data;
@ -478,6 +490,8 @@ static IMMThreadData* IMM_GetInitializedThreadData(void)
HIMC defaultContext;
LeaveCriticalSection(&threaddata_cs);
defaultContext = ImmCreateContext();
if (defaultContext)
((InputContextData*)defaultContext)->threadDefault = TRUE;
thread_data = IMM_GetThreadData(0);
if (!thread_data)
{
@ -780,11 +794,7 @@ static BOOL IMM_DestroyContext(HIMC hIMC)
*/
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
{
IMMThreadData* thread_data = IMM_GetThreadData(0);
HIMC defaultContext = thread_data->defaultContext;
LeaveCriticalSection(&threaddata_cs);
if (hIMC != defaultContext)
if (!IMM_IsDefaultContext(hIMC))
return IMM_DestroyContext(hIMC);
else
return FALSE;