Huw Davies : ole32: In the non-aggregated case a request for IUnknown actually returns IOleCache2.

Alexandre Julliard julliard at winehq.org
Tue Jan 2 15:01:24 CST 2018


Module: wine
Branch: stable
Commit: b1fdac06896b73c55c678699d65a3a78fd6edf1c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b1fdac06896b73c55c678699d65a3a78fd6edf1c

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Oct  5 13:11:06 2017 +0100

ole32: In the non-aggregated case a request for IUnknown actually returns IOleCache2.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 87ccecbfa24e88d80c292d165b3223683b409bfa)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/ole32/datacache.c  | 5 ++++-
 dlls/ole32/tests/ole2.c | 8 +++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index 441a874..71c87fa 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -886,7 +886,10 @@ static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface(
 
   if (IsEqualIID(&IID_IUnknown, riid))
   {
-    *ppvObject = iface;
+    if (this->outer_unk == iface) /* non-aggregated, return IUnknown from IOleCache2 */
+      *ppvObject = &this->IOleCache2_iface;
+    else
+      *ppvObject = iface;
   }
   else if (IsEqualIID(&IID_IDataObject, riid))
   {
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index afff6ba..7367beb 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -1528,7 +1528,7 @@ static void test_data_cache(void)
     IOleCache2 *pOleCache;
     IOleCache *olecache;
     IStorage *pStorage;
-    IUnknown *unk;
+    IUnknown *unk, *unk2;
     IPersistStorage *pPS;
     IViewObject *pViewObject;
     IOleCacheControl *pOleCacheControl;
@@ -1619,10 +1619,12 @@ static void test_data_cache(void)
     ok(hr == S_OK, "got 0x%08x\n", hr);
     hr = IUnknown_QueryInterface(unk, &IID_IOleCache2, (void**)&pOleCache);
     ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine {
+    hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void**)&unk2);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(unk == (IUnknown*)olecache, "got %p, expected %p\n", olecache, unk);
     ok(unk == (IUnknown*)pOleCache, "got %p, expected %p\n", pOleCache, unk);
-}
+    ok(unk == unk2, "got %p, expected %p\n", unk2, unk);
+    IUnknown_Release(unk2);
     IOleCache2_Release(pOleCache);
     IOleCache_Release(olecache);
     IUnknown_Release(unk);




More information about the wine-cvs mailing list