Commit fa4c386e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msctf: Maintain context reference in ranges.

parent 86cbfafe
...@@ -42,7 +42,7 @@ typedef struct tagRange { ...@@ -42,7 +42,7 @@ typedef struct tagRange {
LONG refCount; LONG refCount;
ITextStoreACP *pITextStoreACP; ITextStoreACP *pITextStoreACP;
ITfContext *pITfContext; ITfContext *context;
DWORD lockType; DWORD lockType;
TfGravity gravityStart, gravityEnd; TfGravity gravityStart, gravityEnd;
...@@ -58,6 +58,7 @@ static inline Range *impl_from_ITfRange(ITfRange *iface) ...@@ -58,6 +58,7 @@ static inline Range *impl_from_ITfRange(ITfRange *iface)
static void Range_Destructor(Range *This) static void Range_Destructor(Range *This)
{ {
TRACE("destroying %p\n", This); TRACE("destroying %p\n", This);
ITfContext_Release(This->context);
HeapFree(GetProcessHeap(),0,This); HeapFree(GetProcessHeap(),0,This);
} }
...@@ -282,13 +283,18 @@ static HRESULT WINAPI Range_Clone(ITfRange *iface, ITfRange **ppClone) ...@@ -282,13 +283,18 @@ static HRESULT WINAPI Range_Clone(ITfRange *iface, ITfRange **ppClone)
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI Range_GetContext(ITfRange *iface, ITfContext **ppContext) static HRESULT WINAPI Range_GetContext(ITfRange *iface, ITfContext **context)
{ {
Range *This = impl_from_ITfRange(iface); Range *This = impl_from_ITfRange(iface);
TRACE("(%p)\n",This);
if (!ppContext) TRACE("(%p, %p)\n", This, context);
if (!context)
return E_INVALIDARG; return E_INVALIDARG;
*ppContext = This->pITfContext;
*context = This->context;
ITfContext_AddRef(*context);
return S_OK; return S_OK;
} }
...@@ -334,7 +340,8 @@ HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD l ...@@ -334,7 +340,8 @@ HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD l
This->ITfRange_iface.lpVtbl = &Range_RangeVtbl; This->ITfRange_iface.lpVtbl = &Range_RangeVtbl;
This->refCount = 1; This->refCount = 1;
This->pITfContext = context; This->context = context;
ITfContext_AddRef(This->context);
This->pITextStoreACP = textstore; This->pITextStoreACP = textstore;
This->lockType = lockType; This->lockType = lockType;
This->anchorStart = anchorStart; This->anchorStart = anchorStart;
......
...@@ -228,6 +228,8 @@ static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface, ...@@ -228,6 +228,8 @@ static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
REFIID riid, IUnknown *punk, DWORD dwMask) REFIID riid, IUnknown *punk, DWORD dwMask)
{ {
ITextStoreACPServices *services; ITextStoreACPServices *services;
ITfRangeACP *range;
ITfContext *context;
HRESULT hr; HRESULT hr;
if (winetest_debug > 1) trace("ITextStoreACP::AdviseSink(iid %s, mask %#x)\n", if (winetest_debug > 1) trace("ITextStoreACP::AdviseSink(iid %s, mask %#x)\n",
...@@ -243,6 +245,18 @@ static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface, ...@@ -243,6 +245,18 @@ static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
hr = ITextStoreACPSink_QueryInterface(ACPSink, &IID_ITextStoreACPServices, (void**)&services); hr = ITextStoreACPSink_QueryInterface(ACPSink, &IID_ITextStoreACPServices, (void**)&services);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
range = NULL;
hr = ITextStoreACPServices_CreateRange(services, 0, 1, &range);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
if (range)
{
hr = ITfRangeACP_GetContext(range, &context);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ITfContext_Release(context);
ITfRangeACP_Release(range);
}
ITextStoreACPServices_Release(services); ITextStoreACPServices_Release(services);
return S_OK; return S_OK;
...@@ -2084,10 +2098,11 @@ static void test_InsertAtSelection(TfEditCookie ec, ITfContext *cxt) ...@@ -2084,10 +2098,11 @@ static void test_InsertAtSelection(TfEditCookie ec, ITfContext *cxt)
static HRESULT WINAPI EditSession_DoEditSession(ITfEditSession *iface, static HRESULT WINAPI EditSession_DoEditSession(ITfEditSession *iface,
TfEditCookie ec) TfEditCookie ec)
{ {
ITfContext *cxt; ITfContext *cxt, *context2;
ITfDocumentMgr *dm; ITfDocumentMgr *dm;
ITfRange *range; ITfRange *range;
TF_SELECTION selection; TF_SELECTION selection;
IUnknown *unk;
ULONG fetched; ULONG fetched;
HRESULT hr; HRESULT hr;
...@@ -2109,6 +2124,15 @@ TfEditCookie ec) ...@@ -2109,6 +2124,15 @@ TfEditCookie ec)
ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr); ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr);
ok(range != NULL,"Range set to NULL\n"); ok(range != NULL,"Range set to NULL\n");
hr = ITfRange_GetContext(range, &context2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(context2 == cxt, "Unexpected context pointer.\n");
ITfContext_Release(context2);
hr = ITfRange_QueryInterface(range, &IID_ITfRangeACP, (void **)&unk);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ITfRange_Release(range); ITfRange_Release(range);
hr = ITfContext_GetEnd(cxt,ec,NULL); hr = ITfContext_GetEnd(cxt,ec,NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment