From ccb634fdee50936c35880a6cffd70e0bcd946b5a Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Thu, 31 Aug 2006 17:14:38 +0100 Subject: [PATCH] ole32: Re-structure OleCreate to match to order of calls that native does. Get rid of hres1 since all failures are returned. Cleanup pUnk on failure and make sure to return NULL in ppvObj. --- dlls/ole32/ole2.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index a5354cc9404..4ae9619ffb9 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c @@ -2299,8 +2299,9 @@ HRESULT WINAPI OleCreate( LPSTORAGE pStg, LPVOID* ppvObj) { - HRESULT hres, hres1; + HRESULT hres; IUnknown * pUnk = NULL; + IOleObject *pOleObject = NULL; FIXME("\n\t%s\n\t%s semi-stub!\n", debugstr_guid(rclsid), debugstr_guid(riid)); @@ -2309,29 +2310,37 @@ HRESULT WINAPI OleCreate( if (SUCCEEDED(hres)) hres = IStorage_SetClass(pStg, rclsid); + if (pClientSite && SUCCEEDED(hres)) + hres = IUnknown_QueryInterface(pUnk, &IID_IOleObject, (LPVOID*)&pOleObject); + if (SUCCEEDED(hres)) { - if (pClientSite) + IPersistStorage * pPS; + if (SUCCEEDED((hres = IUnknown_QueryInterface(pUnk, &IID_IPersistStorage, (LPVOID*)&pPS)))) { - IOleObject * pOE; - IPersistStorage * pPS; - if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IOleObject, (LPVOID*)&pOE)))) - { - TRACE("trying to set clientsite %p\n", pClientSite); - hres1 = IOleObject_SetClientSite(pOE, pClientSite); - TRACE("-- result 0x%08lx\n", hres1); - IOleObject_Release(pOE); - } - if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS)))) - { - TRACE("trying to set stg %p\n", pStg); - hres1 = IPersistStorage_InitNew(pPS, pStg); - TRACE("-- result 0x%08lx\n", hres1); - IPersistStorage_Release(pPS); - } + TRACE("trying to set stg %p\n", pStg); + hres = IPersistStorage_InitNew(pPS, pStg); + TRACE("-- result 0x%08lx\n", hres); + IPersistStorage_Release(pPS); } } + if (pClientSite && SUCCEEDED(hres)) + { + TRACE("trying to set clientsite %p\n", pClientSite); + hres = IOleObject_SetClientSite(pOleObject, pClientSite); + TRACE("-- result 0x%08lx\n", hres); + } + + if (pOleObject) + IOleObject_Release(pOleObject); + + if (FAILED(hres)) + { + IUnknown_Release(pUnk); + pUnk = NULL; + } + *ppvObj = pUnk; TRACE("-- %p\n", pUnk); -- 2.11.4.GIT