msctf: Only 1 ITfThreadMgr is created per thread.
This commit is contained in:
parent
9105cd88c4
commit
8b34370d7c
|
@ -43,6 +43,8 @@ static LONG MSCTF_refCount;
|
|||
|
||||
static HINSTANCE MSCTF_hinstance;
|
||||
|
||||
DWORD tlsIndex = 0;
|
||||
|
||||
typedef HRESULT (*LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
|
||||
|
||||
static const struct {
|
||||
|
@ -159,8 +161,11 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
|
|||
case DLL_WINE_PREATTACH:
|
||||
return FALSE; /* prefer native version */
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hinst);
|
||||
MSCTF_hinstance = hinst;
|
||||
tlsIndex = TlsAlloc();
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
TlsFree(tlsIndex);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#ifndef __WINE_MSCTF_I_H
|
||||
#define __WINE_MSCTF_I_H
|
||||
extern DWORD tlsIndex;
|
||||
|
||||
extern HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
|
||||
extern HRESULT DocumentMgr_Constructor(ITfDocumentMgr **ppOut);
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct tagACLMulti {
|
|||
|
||||
static void ThreadMgr_Destructor(ThreadMgr *This)
|
||||
{
|
||||
TlsSetValue(tlsIndex,NULL);
|
||||
TRACE("destroying %p\n", This);
|
||||
if (This->focus)
|
||||
ITfDocumentMgr_Release(This->focus);
|
||||
|
@ -227,12 +228,22 @@ HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
|
|||
if (pUnkOuter)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
||||
/* Only 1 ThreadMgr is created per thread */
|
||||
This = TlsGetValue(tlsIndex);
|
||||
if (This)
|
||||
{
|
||||
ThreadMgr_AddRef((ITfThreadMgr*)This);
|
||||
*ppOut = (IUnknown*)This;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
|
||||
if (This == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
|
||||
This->refCount = 1;
|
||||
TlsSetValue(tlsIndex,This);
|
||||
|
||||
TRACE("returning %p\n", This);
|
||||
*ppOut = (IUnknown *)This;
|
||||
|
|
Loading…
Reference in New Issue