Aric Stewart : imm32: Do not let ImmDestroyContext destroy any default contexts.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 26 09:17:00 CST 2015
Module: wine
Branch: master
Commit: f3967902c5e5684d20429caddd81d31a6f211b9a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f3967902c5e5684d20429caddd81d31a6f211b9a
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed Feb 25 11:45:18 2015 -0600
imm32: Do not let ImmDestroyContext destroy any default contexts.
---
dlls/imm32/imm.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 9dbdc1a..db5939c 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -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;
More information about the wine-cvs
mailing list