oleaut32: Implicitly initialize COM in OleLoadPicturePath.

This commit is contained in:
Andrew Nguyen 2010-05-19 22:26:22 -05:00 committed by Alexandre Julliard
parent 61f7f77636
commit 96dbdcb8c9
2 changed files with 21 additions and 25 deletions

View File

@ -2273,6 +2273,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
BOOL bRead; BOOL bRead;
IPersistStream *pStream; IPersistStream *pStream;
HRESULT hRes; HRESULT hRes;
HRESULT init_res;
WCHAR *file_candidate; WCHAR *file_candidate;
WCHAR path_buf[MAX_PATH]; WCHAR path_buf[MAX_PATH];
@ -2349,34 +2350,32 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
return hRes; return hRes;
} }
init_res = CoInitialize(NULL);
hRes = CoCreateInstance(&CLSID_StdPicture, punkCaller, CLSCTX_INPROC_SERVER, hRes = CoCreateInstance(&CLSID_StdPicture, punkCaller, CLSCTX_INPROC_SERVER,
&IID_IPicture, (LPVOID*)&ipicture); &IID_IPicture, (LPVOID*)&ipicture);
if (hRes != S_OK) { if (SUCCEEDED(hRes)) {
IStream_Release(stream); hRes = IPicture_QueryInterface(ipicture, &IID_IPersistStream, (LPVOID*)&pStream);
return hRes;
}
hRes = IPicture_QueryInterface(ipicture, &IID_IPersistStream, (LPVOID*)&pStream); if (SUCCEEDED(hRes)) {
if (hRes) { hRes = IPersistStream_Load(pStream, stream);
IStream_Release(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); IPicture_Release(ipicture);
return hRes;
} }
hRes = IPersistStream_Load(pStream, stream);
IPersistStream_Release(pStream);
IStream_Release(stream); IStream_Release(stream);
if (hRes) { if (SUCCEEDED(init_res))
IPicture_Release(ipicture); CoUninitialize();
return hRes;
}
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; return hRes;
} }

View File

@ -813,7 +813,6 @@ static void test_OleLoadPicturePath(void)
/* Try a normal DOS path. */ /* Try a normal DOS path. */
hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic); hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
todo_wine
ok(hres == S_OK || ok(hres == S_OK ||
broken(hres == E_UNEXPECTED), /* NT4/Win95 */ broken(hres == E_UNEXPECTED), /* NT4/Win95 */
"Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres); "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:". */ /* Try a DOS path with tacked on "file:". */
hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic); hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
todo_wine
ok(hres == S_OK || ok(hres == S_OK ||
broken(hres == E_UNEXPECTED), /* NT4/Win95 */ broken(hres == E_UNEXPECTED), /* NT4/Win95 */
"Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres); "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); hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
todo_wine
ok(hres == S_OK || ok(hres == S_OK ||
broken(hres == E_UNEXPECTED), /* NT4/Win95 */ broken(hres == E_UNEXPECTED), /* NT4/Win95 */
"Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres); "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);