Andrew Nguyen : oleaut32: Implicitly initialize COM in OleLoadPicturePath.

Alexandre Julliard julliard at winehq.org
Thu May 20 11:03:03 CDT 2010


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

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Wed May 19 22:26:22 2010 -0500

oleaut32: Implicitly initialize COM in OleLoadPicturePath.

---

 dlls/oleaut32/olepicture.c       |   43 ++++++++++++++++++-------------------
 dlls/oleaut32/tests/olepicture.c |    3 --
 2 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index 07d4dde..b8e949d 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -2273,6 +2273,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
   BOOL bRead;
   IPersistStream *pStream;
   HRESULT hRes;
+  HRESULT init_res;
   WCHAR *file_candidate;
   WCHAR path_buf[MAX_PATH];
 
@@ -2349,34 +2350,32 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
 	  return hRes;
   }
 
-  hRes = CoCreateInstance(&CLSID_StdPicture, punkCaller, CLSCTX_INPROC_SERVER, 
-		   &IID_IPicture, (LPVOID*)&ipicture);
-  if (hRes != S_OK) {
-      IStream_Release(stream);
-      return hRes;
-  }
-  
-  hRes = IPicture_QueryInterface(ipicture, &IID_IPersistStream, (LPVOID*)&pStream);
-  if (hRes) {
-      IStream_Release(stream);
+  init_res = CoInitialize(NULL);
+
+  hRes = CoCreateInstance(&CLSID_StdPicture, punkCaller, CLSCTX_INPROC_SERVER,
+                          &IID_IPicture, (LPVOID*)&ipicture);
+  if (SUCCEEDED(hRes)) {
+      hRes = IPicture_QueryInterface(ipicture, &IID_IPersistStream, (LPVOID*)&pStream);
+
+      if (SUCCEEDED(hRes)) {
+          hRes = IPersistStream_Load(pStream, stream);
+
+          if (SUCCEEDED(hRes)) {
+              hRes = IPicture_QueryInterface(ipicture, riid, ppvRet);
+
+              if (FAILED(hRes))
+                  ERR("Failed to get interface %s from IPicture.\n", debugstr_guid(riid));
+          }
+          IPersistStream_Release(pStream);
+      }
       IPicture_Release(ipicture);
-      return hRes;
   }
 
-  hRes = IPersistStream_Load(pStream, stream); 
-  IPersistStream_Release(pStream);
   IStream_Release(stream);
 
-  if (hRes) {
-      IPicture_Release(ipicture);
-      return hRes;
-  }
+  if (SUCCEEDED(init_res))
+      CoUninitialize();
 
-  hRes = IPicture_QueryInterface(ipicture,riid,ppvRet);
-  if (hRes)
-      ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
-  
-  IPicture_Release(ipicture);
   return hRes;
 }
 
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 6bf3c44..8ea1a2a 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -813,7 +813,6 @@ static void test_OleLoadPicturePath(void)
 
     /* Try a normal DOS path. */
     hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
-    todo_wine
     ok(hres == S_OK ||
        broken(hres == E_UNEXPECTED), /* NT4/Win95 */
        "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);
@@ -822,7 +821,6 @@ static void test_OleLoadPicturePath(void)
 
     /* Try a DOS path with tacked on "file:". */
     hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
-    todo_wine
     ok(hres == S_OK ||
        broken(hres == E_UNEXPECTED), /* NT4/Win95 */
        "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);
@@ -859,7 +857,6 @@ static void test_OleLoadPicturePath(void)
     }
 
     hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
-    todo_wine
     ok(hres == S_OK ||
        broken(hres == E_UNEXPECTED), /* NT4/Win95 */
        "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);




More information about the wine-cvs mailing list