Module: wine Branch: master Commit: 7d4e1336247bb701e9e23ef4f36909793e70c25a URL: http://source.winehq.org/git/wine.git/?a=commit;h=7d4e1336247bb701e9e23ef4f3...
Author: Aric Stewart aric@codeweavers.com Date: Fri May 15 14:09:58 2009 -0500
msctf: TfContext intitalization and uninitialization on Push and Pop.
---
dlls/msctf/context.c | 39 ++++++++++++++++++++++++++++++++------- dlls/msctf/documentmgr.c | 4 ++++ dlls/msctf/msctf_internal.h | 3 +++ 3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c index dff4fd8..42ae71e 100644 --- a/dlls/msctf/context.c +++ b/dlls/msctf/context.c @@ -66,6 +66,7 @@ typedef struct tagContext { /* const ITfQueryEmbeddedVtbl *QueryEmbeddedVtbl; */ /* const ITfSourceSingleVtbl *SourceSingleVtbl; */ LONG refCount; + BOOL connected;
TfClientId tidOwner;
@@ -446,16 +447,12 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp This->SourceVtbl = &Context_SourceVtbl; This->refCount = 1; This->tidOwner = tidOwner; + This->connected = FALSE;
if (punk) { - if (SUCCEEDED(IUnknown_QueryInterface(punk, &IID_ITextStoreACP, - (LPVOID*)&This->pITextStoreACP))) - { - if (SUCCEEDED(TextStoreACPSink_Constructor(&This->pITextStoreACPSink, This))) - ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink, - (IUnknown*)This->pITextStoreACPSink, TS_AS_ALL_SINKS); - } + IUnknown_QueryInterface(punk, &IID_ITextStoreACP, + (LPVOID*)&This->pITextStoreACP);
IUnknown_QueryInterface(punk, &IID_ITfContextOwnerCompositionSink, (LPVOID*)&This->pITfContextOwnerCompositionSink); @@ -478,6 +475,34 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp return S_OK; }
+HRESULT Context_Initialize(ITfContext *iface) +{ + Context *This = (Context *)iface; + + if (This->pITextStoreACP) + { + if (SUCCEEDED(TextStoreACPSink_Constructor(&This->pITextStoreACPSink, This))) + ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink, + (IUnknown*)This->pITextStoreACPSink, TS_AS_ALL_SINKS); + } + This->connected = TRUE; + return S_OK; +} + +HRESULT Context_Uninitialize(ITfContext *iface) +{ + Context *This = (Context *)iface; + + if (This->pITextStoreACPSink) + { + ITextStoreACP_UnadviseSink(This->pITextStoreACP, (IUnknown*)This->pITextStoreACPSink); + if (ITextStoreACPSink_Release(This->pITextStoreACPSink) == 0) + This->pITextStoreACPSink = NULL; + } + This->connected = FALSE; + return S_OK; +} + /************************************************************************** * ITextStoreACPSink **************************************************************************/ diff --git a/dlls/msctf/documentmgr.c b/dlls/msctf/documentmgr.c index e1e5b19..7fd354a 100644 --- a/dlls/msctf/documentmgr.c +++ b/dlls/msctf/documentmgr.c @@ -138,6 +138,7 @@ static HRESULT WINAPI DocumentMgr_Push(ITfDocumentMgr *iface, ITfContext *pic) This->contextStack[0] = check;
ITfThreadMgrEventSink_OnPushContext(This->ThreadMgrSink,check); + Context_Initialize(check);
return S_OK; } @@ -153,11 +154,13 @@ static HRESULT WINAPI DocumentMgr_Pop(ITfDocumentMgr *iface, DWORD dwFlags) { ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[0]); ITfContext_Release(This->contextStack[0]); + Context_Uninitialize(This->contextStack[0]); } if (This->contextStack[1]) { ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[1]); ITfContext_Release(This->contextStack[1]); + Context_Uninitialize(This->contextStack[1]); } This->contextStack[0] = This->contextStack[1] = NULL; ITfThreadMgrEventSink_OnUninitDocumentMgr(This->ThreadMgrSink, iface); @@ -172,6 +175,7 @@ static HRESULT WINAPI DocumentMgr_Pop(ITfDocumentMgr *iface, DWORD dwFlags)
ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[0]); ITfContext_Release(This->contextStack[0]); + Context_Uninitialize(This->contextStack[0]); This->contextStack[0] = This->contextStack[1]; This->contextStack[1] = NULL;
diff --git a/dlls/msctf/msctf_internal.h b/dlls/msctf/msctf_internal.h index 15950ed..3dce778 100644 --- a/dlls/msctf/msctf_internal.h +++ b/dlls/msctf/msctf_internal.h @@ -35,6 +35,9 @@ extern HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfConte extern HRESULT InputProcessorProfiles_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut); extern HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
+extern HRESULT Context_Initialize(ITfContext *cxt); +extern HRESULT Context_Uninitialize(ITfContext *cxt); + /* cookie function */ extern DWORD generate_Cookie(DWORD magic, LPVOID data); extern DWORD get_Cookie_magic(DWORD id);