[2/4] shell32: Use QueryInterface in FolderView_GetFolder.

Thomas Faber thomas.faber at reactos.org
Mon Jun 29 16:10:22 CDT 2015


test_IFolderView has a test that shows that the shell folder's
reference count before and after the call to IFolderView_GetFolder is
the same.
However this is misleading because it is not a property of the
IFolderView_GetFolder method, but of the desktop shell folder object
that's used in the folder view. Windows <=2003 uses a cached object
just like Wine does and its AddRef/Release methods return constants.
This changed with Vista (see e.g. the test failures in
https://testbot.winehq.org/JobDetails.pl?Key=14756 -- now multiple
SHGetDesktopFolder calls return different objects), hence why the
reference counting works as expected there.

In conclusion: GetFolder works like any proper COM method should and
takes a reference to the folder. Thus it is properly implemented by
using QueryInterface.
-------------- next part --------------
From 36cffd046b443b33bc455622ed858c692309966d Mon Sep 17 00:00:00 2001
From: Thomas Faber <thomas.faber at reactos.org>
Date: Mon, 29 Jun 2015 15:39:25 -0400
Subject: shell32: Use QueryInterface in FolderView_GetFolder.

---
 dlls/shell32/shlview.c       |   10 +---------
 dlls/shell32/tests/shlview.c |    5 +++++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index e6691f8..b763468 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -2713,15 +2713,7 @@ static HRESULT WINAPI FolderView_GetFolder(IFolderView2 *iface, REFIID riid, voi
 
     TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
 
-    if (!ppv) return E_POINTER;
-
-    if (IsEqualIID(riid, &IID_IShellFolder))
-    {
-        *ppv = This->pSFParent;
-        return S_OK;
-    }
-
-    return E_NOINTERFACE;
+    return IShellFolder_QueryInterface(This->pSFParent, riid, ppv);
 }
 
 static HRESULT WINAPI FolderView_Item(IFolderView2 *iface, int index, PITEMID_CHILD *ppidl)
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c
index 6525dd2..05fc7ee 100644
--- a/dlls/shell32/tests/shlview.c
+++ b/dlls/shell32/tests/shlview.c
@@ -688,6 +688,7 @@ static void test_IFolderView(void)
     IShellBrowser *browser;
     IFolderView2 *fv2;
     IFolderView *fv;
+    IUnknown *unk;
     HWND hwnd_view, hwnd_list;
     PITEMID_CHILD pidl;
     HRESULT hr;
@@ -831,6 +832,10 @@ if (0)
        "expected same refcount, got %d\n", ref2);
     ok(desktop == folder, "\n");
 
+    hr = IFolderView_GetFolder(fv, &IID_IUnknown, (void**)&unk);
+    ok(hr == S_OK, "got (0x%08x)\n", hr);
+    if (unk) IUnknown_Release(unk);
+
     hr = IFolderView_QueryInterface(fv, &IID_IFolderView2, (void**)&fv2);
     if (hr != S_OK)
         win_skip("IFolderView2 is not supported.\n");
-- 
1.7.1



More information about the wine-patches mailing list