Module: wine Branch: master Commit: d917f0ef096d55928e1631a77cda1e683c906f07 URL: https://source.winehq.org/git/wine.git/?a=commit;h=d917f0ef096d55928e1631a77...
Author: Sven Baars sven.wine@gmail.com Date: Wed Jan 30 22:03:20 2019 +0100
riched20: Fix IRichEditOle COM aggregation (Valgrind).
Signed-off-by: Sven Baars sven.wine@gmail.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/riched20/editor.c | 13 ++++++++----- dlls/riched20/editor.h | 1 - dlls/riched20/editstr.h | 2 +- dlls/riched20/richole.c | 8 +------- dlls/riched20/txtsrv.c | 5 +---- 5 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 2bb2858..b7254d2 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1124,6 +1124,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB LPOLECLIENTSITE lpClientSite = NULL; LPDATAOBJECT lpDataObject = NULL; LPOLECACHE lpOleCache = NULL; + LPRICHEDITOLE lpReOle = NULL; STGMEDIUM stgm; FORMATETC fm; CLSID clsid; @@ -1156,7 +1157,8 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB }
if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject, (void**)&lpObject) == S_OK && - IRichEditOle_GetClientSite(editor->reOle, &lpClientSite) == S_OK && + IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (void**)&lpReOle) == S_OK && + IRichEditOle_GetClientSite(lpReOle, &lpClientSite) == S_OK && IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK && IOleObject_GetUserClassID(lpObject, &clsid) == S_OK && IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) == S_OK && @@ -1188,6 +1190,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB if (lpStorage) IStorage_Release(lpStorage); if (lpDataObject) IDataObject_Release(lpDataObject); if (lpOleCache) IOleCache_Release(lpOleCache); + if (lpReOle) IRichEditOle_Release(lpReOle);
return hr; } @@ -3215,7 +3218,7 @@ void ME_DestroyEditor(ME_TextEditor *editor) ITextHost_Release(editor->texthost); if (editor->reOle) { - IRichEditOle_Release(editor->reOle); + IUnknown_Release(editor->reOle); editor->reOle = NULL; } OleUninitialize(); @@ -4820,9 +4823,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, if (!editor->reOle) if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle)) return 0; - *(LPVOID *)lParam = editor->reOle; - IRichEditOle_AddRef(editor->reOle); - return 1; + if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID *)lParam) == S_OK) + return 1; + return 0; } case EM_GETPASSWORDCHAR: { diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 2da7365..2633fa8 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -239,7 +239,6 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL selected) DECLSPE void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN; void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN; void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN; -void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN;
/* editor.c */ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 96c9a1f..28be524 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -385,7 +385,7 @@ typedef struct tagME_TextEditor { HWND hWnd, hwndParent; ITextHost *texthost; - IRichEditOle *reOle; + IUnknown *reOle; BOOL bEmulateVersion10; ME_TextBuffer *pBuffer; ME_Cursor *pCursors; diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index dc1a3b8..447e7d4 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -5471,7 +5471,7 @@ LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *p reo->outer_unk = outer_unk; else reo->outer_unk = &reo->IUnknown_inner; - *ppvObj = &reo->IRichEditOle_iface; + *ppvObj = &reo->IUnknown_inner;
return 1; } @@ -5691,9 +5691,3 @@ void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) IOleClientSite_AddRef(dst->polesite); } } - -void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) -{ - IRichEditOleImpl *This = impl_from_IRichEditOle(iface); - *ppvObj = &This->ITextDocument2Old_iface; -} diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 18c2ca9..639a94f 100644 --- a/dlls/riched20/txtsrv.c +++ b/dlls/riched20/txtsrv.c @@ -83,10 +83,7 @@ static HRESULT WINAPI ITextServicesImpl_QueryInterface(IUnknown *iface, REFIID r if (!This->editor->reOle) if (!CreateIRichEditOle(This->outer_unk, This->editor, (void **)(&This->editor->reOle))) return E_OUTOFMEMORY; - if (IsEqualIID(riid, &IID_ITextDocument) || IsEqualIID(riid, &IID_ITextDocument2Old)) - ME_GetITextDocument2OldInterface(This->editor->reOle, ppv); - else - *ppv = This->editor->reOle; + return IUnknown_QueryInterface(This->editor->reOle, riid, ppv); } else { *ppv = NULL; FIXME("Unknown interface: %s\n", debugstr_guid(riid));