[PATCH 1/4] msctf: Maintain context reference in ranges.
Nikolay Sivov
nsivov at codeweavers.com
Wed Jun 2 09:08:48 CDT 2021
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/msctf/range.c | 19 +++++++++++++------
dlls/msctf/tests/inputprocessor.c | 26 +++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/dlls/msctf/range.c b/dlls/msctf/range.c
index c4eee2501fb..85922791bad 100644
--- a/dlls/msctf/range.c
+++ b/dlls/msctf/range.c
@@ -42,7 +42,7 @@ typedef struct tagRange {
LONG refCount;
ITextStoreACP *pITextStoreACP;
- ITfContext *pITfContext;
+ ITfContext *context;
DWORD lockType;
TfGravity gravityStart, gravityEnd;
@@ -58,6 +58,7 @@ static inline Range *impl_from_ITfRange(ITfRange *iface)
static void Range_Destructor(Range *This)
{
TRACE("destroying %p\n", This);
+ ITfContext_Release(This->context);
HeapFree(GetProcessHeap(),0,This);
}
@@ -282,13 +283,18 @@ static HRESULT WINAPI Range_Clone(ITfRange *iface, ITfRange **ppClone)
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);
- TRACE("(%p)\n",This);
- if (!ppContext)
+
+ TRACE("(%p, %p)\n", This, context);
+
+ if (!context)
return E_INVALIDARG;
- *ppContext = This->pITfContext;
+
+ *context = This->context;
+ ITfContext_AddRef(*context);
+
return S_OK;
}
@@ -334,7 +340,8 @@ HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD l
This->ITfRange_iface.lpVtbl = &Range_RangeVtbl;
This->refCount = 1;
- This->pITfContext = context;
+ This->context = context;
+ ITfContext_AddRef(This->context);
This->pITextStoreACP = textstore;
This->lockType = lockType;
This->anchorStart = anchorStart;
diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c
index 55a6ab6c34c..fd03059e545 100644
--- a/dlls/msctf/tests/inputprocessor.c
+++ b/dlls/msctf/tests/inputprocessor.c
@@ -228,6 +228,8 @@ static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
REFIID riid, IUnknown *punk, DWORD dwMask)
{
ITextStoreACPServices *services;
+ ITfRangeACP *range;
+ ITfContext *context;
HRESULT hr;
if (winetest_debug > 1) trace("ITextStoreACP::AdviseSink(iid %s, mask %#x)\n",
@@ -243,6 +245,18 @@ static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
hr = ITextStoreACPSink_QueryInterface(ACPSink, &IID_ITextStoreACPServices, (void**)&services);
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);
return S_OK;
@@ -2084,10 +2098,11 @@ static void test_InsertAtSelection(TfEditCookie ec, ITfContext *cxt)
static HRESULT WINAPI EditSession_DoEditSession(ITfEditSession *iface,
TfEditCookie ec)
{
- ITfContext *cxt;
+ ITfContext *cxt, *context2;
ITfDocumentMgr *dm;
ITfRange *range;
TF_SELECTION selection;
+ IUnknown *unk;
ULONG fetched;
HRESULT hr;
@@ -2109,6 +2124,15 @@ TfEditCookie ec)
ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr);
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);
hr = ITfContext_GetEnd(cxt,ec,NULL);
--
2.30.2
More information about the wine-devel
mailing list