[PATCH 4/5] riched20: Don't take a ref on the text host.
Huw Davies
huw at codeweavers.com
Wed Mar 3 05:29:40 CST 2021
This would result in the host and services objects holding
refs on each other.
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/riched20/editor.c | 1 -
dlls/riched20/tests/txtsrv.c | 1 +
dlls/riched20/txtsrv.c | 5 ++---
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 487d4137391..516cd104d31 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3221,7 +3221,6 @@ void ME_DestroyEditor(ME_TextEditor *editor)
DeleteObject(editor->hbrBackground);
if(editor->lpOleCallback)
IRichEditOleCallback_Release(editor->lpOleCallback);
- ITextHost_Release(editor->texthost);
if (editor->reOle)
{
IUnknown_Release(editor->reOle);
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c
index 1528bef5238..f41375d871a 100644
--- a/dlls/riched20/tests/txtsrv.c
+++ b/dlls/riched20/tests/txtsrv.c
@@ -602,6 +602,7 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
ITextServices object. */
result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init);
ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result);
+ ok(dummyTextHost->refCount == 1, "host ref %d\n", dummyTextHost->refCount);
if (result != S_OK) {
CoTaskMemFree(dummyTextHost);
win_skip("CreateTextServices failed.\n");
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 6f8e3cd3fa3..fc8d6765424 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -38,7 +38,7 @@ struct text_services
ITextServices ITextServices_iface;
IUnknown *outer_unk;
LONG ref;
- ITextHost *pMyHost;
+ ITextHost *host;
CRITICAL_SECTION csTxtSrv;
ME_TextEditor *editor;
char spare[256];
@@ -385,8 +385,7 @@ HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, I
InitializeCriticalSection(&ITextImpl->csTxtSrv);
ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
ITextImpl->ref = 1;
- ITextHost_AddRef(pITextHost);
- ITextImpl->pMyHost = pITextHost;
+ ITextImpl->host = pITextHost; /* Don't take a ref of the host - this would lead to a mutual dependency */
ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl;
ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE);
--
2.23.0
More information about the wine-devel
mailing list