Robert Shearman : ole32: Re-structure OleCreate to match to order of calls that native does.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Sep 7 05:07:13 CDT 2006


Module: wine
Branch: master
Commit: ccb634fdee50936c35880a6cffd70e0bcd946b5a
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=ccb634fdee50936c35880a6cffd70e0bcd946b5a

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Aug 31 17:14:38 2006 +0100

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 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c
index a5354cc..4ae9619 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);




More information about the wine-cvs mailing list