[PATCH 3/3] shell32: Move the pidl handling to the ExtractIcon_Constructor [try 2]

Detlef Riekenberg wine.dev at web.de
Sun May 20 18:36:53 CDT 2012


The function is now similar to the IQueryInfo_Constructor

try 2:
remove unneeded ILClone and pass the REFIID to the extracticon constructor

Thanks nikolay for the hints

--
By by ... Detlef
---
 dlls/shell32/cpanelfolder.c     |   12 ++----------
 dlls/shell32/folders.c          |   37 ++++++++++++++++---------------------
 dlls/shell32/shell32_main.h     |    3 +--
 dlls/shell32/shfldr_desktop.c   |   14 ++------------
 dlls/shell32/shfldr_fs.c        |   12 ++----------
 dlls/shell32/shfldr_mycomp.c    |   14 ++------------
 dlls/shell32/shfldr_netplaces.c |   15 ++-------------
 dlls/shell32/shfldr_unixfs.c    |   15 ++-------------
 8 files changed, 29 insertions(+), 93 deletions(-)

diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c
index 1229e47..0b25a7d 100644
--- a/dlls/shell32/cpanelfolder.c
+++ b/dlls/shell32/cpanelfolder.c
@@ -604,16 +604,8 @@ static HRESULT WINAPI ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 *iface, HWN
 	} else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
 	    pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
 	    hr = S_OK;
-	} else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
-	    pidl = ILCombine(This->pidlRoot, apidl[0]);
-	    pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
-	    SHFree(pidl);
-	    hr = S_OK;
-	} else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
-	    pidl = ILCombine(This->pidlRoot, apidl[0]);
-	    pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
-	    SHFree(pidl);
-	    hr = S_OK;
+        } else if ((IsEqualIID(riid, &IID_IExtractIconA) || IsEqualIID(riid, &IID_IExtractIconW)) && (cidl == 1)) {
+            return IExtractIconAW_Constructor(This->pidlRoot, apidl[0], riid, ppvOut);
 	} else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
 				&& (cidl == 1)) {
 	    pidl = ILCombine(This->pidlRoot, apidl[0]);
diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c
index 42e3304..f8f7e6b 100644
--- a/dlls/shell32/folders.c
+++ b/dlls/shell32/folders.c
@@ -544,37 +544,32 @@ static const IPersistFileVtbl pfvt =
 	(void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
 };
 
-static IExtractIconWImpl *extracticon_create(LPCITEMIDLIST pidl)
+
+HRESULT IExtractIconAW_Constructor(LPCITEMIDLIST root, LPCITEMIDLIST item, REFIID riid, void ** ppvOut)
 {
-    IExtractIconWImpl *ei;
+    IExtractIconWImpl *ei = HeapAlloc(GetProcessHeap(), 0, sizeof(IExtractIconWImpl));
 
-    TRACE("%p\n", pidl);
+    if (!ei)
+        return E_OUTOFMEMORY;
 
-    ei = HeapAlloc(GetProcessHeap(), 0, sizeof(*ei));
     ei->ref=1;
     ei->IExtractIconW_iface.lpVtbl = &eivt;
     ei->IExtractIconA_iface.lpVtbl = &eiavt;
     ei->IPersistFile_iface.lpVtbl = &pfvt;
-    ei->pidl=ILClone(pidl);
-
-    pdump(pidl);
-
-    TRACE("(%p)\n", ei);
-    return ei;
-}
-
-IExtractIconW *IExtractIconW_Constructor(LPCITEMIDLIST pidl)
-{
-    IExtractIconWImpl *ei = extracticon_create(pidl);
+    ei->pidl = ILCombine(root, item);
 
-    return &ei->IExtractIconW_iface;
-}
+    if (!ei->pidl) {
+        HeapFree(GetProcessHeap(), 0, ei);
+        return E_OUTOFMEMORY;
+    }
 
-IExtractIconA *IExtractIconA_Constructor(LPCITEMIDLIST pidl)
-{
-    IExtractIconWImpl *ei = extracticon_create(pidl);
+    if (IsEqualIID(&IID_IExtractIconW, riid))
+        *ppvOut = &ei->IExtractIconW_iface;
+    else
+        *ppvOut = &ei->IExtractIconA_iface;
 
-    return &ei->IExtractIconA_iface;
+    TRACE("==> %p (pidl: %p)\n", *ppvOut, ei->pidl);
+    return S_OK;
 }
 
 /***********************************************************************
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
index 2c55685..820e5f1 100644
--- a/dlls/shell32/shell32_main.h
+++ b/dlls/shell32/shell32_main.h
@@ -110,8 +110,7 @@ HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVO
 HRESULT WINAPI ApplicationAssociationRegistration_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
 
 
-LPEXTRACTICONA	IExtractIconA_Constructor(LPCITEMIDLIST) DECLSPEC_HIDDEN;
-LPEXTRACTICONW	IExtractIconW_Constructor(LPCITEMIDLIST) DECLSPEC_HIDDEN;
+HRESULT IExtractIconAW_Constructor(LPCITEMIDLIST, LPCITEMIDLIST, REFIID, void **) DECLSPEC_HIDDEN;
 HRESULT IQueryInfo_Constructor(LPCITEMIDLIST, LPCITEMIDLIST, void **) DECLSPEC_HIDDEN;
 
 /* initialisation for FORMATETC */
diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c
index 43d4108..4f7ae98 100644
--- a/dlls/shell32/shfldr_desktop.c
+++ b/dlls/shell32/shfldr_desktop.c
@@ -540,19 +540,9 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
                                                   This->pidlRoot, apidl, cidl);
         hr = S_OK;
     }
-    else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
+    else if ((IsEqualIID (riid, &IID_IExtractIconA) || IsEqualIID (riid, &IID_IExtractIconW)) && (cidl == 1))
     {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
-    }
-    else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
-    {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
+        return IExtractIconAW_Constructor (This->pidlRoot, apidl[0], riid, ppvOut);
     }
     else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
     {
diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c
index 3bbe26e..ffbad46 100644
--- a/dlls/shell32/shfldr_fs.c
+++ b/dlls/shell32/shfldr_fs.c
@@ -749,16 +749,8 @@ IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface,
             pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner,
              This->pidlRoot, apidl, cidl);
             hr = S_OK;
-        } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
-            pidl = ILCombine (This->pidlRoot, apidl[0]);
-            pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-            SHFree (pidl);
-            hr = S_OK;
-        } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
-            pidl = ILCombine (This->pidlRoot, apidl[0]);
-            pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
-            SHFree (pidl);
-            hr = S_OK;
+        } else if ((IsEqualIID (riid, &IID_IExtractIconA) || IsEqualIID (riid, &IID_IExtractIconW)) && (cidl == 1)) {
+            return IExtractIconAW_Constructor (This->pidlRoot, apidl[0], riid, ppvOut);
         } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
             hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget,
              (LPVOID *) & pObj);
diff --git a/dlls/shell32/shfldr_mycomp.c b/dlls/shell32/shfldr_mycomp.c
index 200ad86..f259700 100644
--- a/dlls/shell32/shfldr_mycomp.c
+++ b/dlls/shell32/shfldr_mycomp.c
@@ -540,19 +540,9 @@ static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
                                               This->pidlRoot, apidl, cidl);
         hr = S_OK;
     }
-    else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
+    else if ((IsEqualIID (riid, &IID_IExtractIconA) || IsEqualIID (riid, &IID_IExtractIconW)) && (cidl == 1))
     {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
-    }
-    else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
-    {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
+        return IExtractIconAW_Constructor (This->pidlRoot, apidl[0], riid, ppvOut);
     }
     else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
     {
diff --git a/dlls/shell32/shfldr_netplaces.c b/dlls/shell32/shfldr_netplaces.c
index 39f748b..0d419e1 100644
--- a/dlls/shell32/shfldr_netplaces.c
+++ b/dlls/shell32/shfldr_netplaces.c
@@ -412,7 +412,6 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface,
 {
     IGenericSFImpl *This = impl_from_IShellFolder2(iface);
 
-    LPITEMIDLIST pidl;
     IUnknown *pObj = NULL;
     HRESULT hr = E_INVALIDARG;
 
@@ -433,19 +432,9 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface,
         pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
         hr = S_OK;
     }
-    else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
+    else if ((IsEqualIID (riid, &IID_IExtractIconA) || IsEqualIID (riid, &IID_IExtractIconW)) && (cidl == 1))
     {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
-    }
-    else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
-    {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
+        return IExtractIconAW_Constructor (This->pidlRoot, apidl[0], riid, ppvOut);
     }
     else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
     {
diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c
index c15d0ce..b44c2f7 100644
--- a/dlls/shell32/shfldr_unixfs.c
+++ b/dlls/shell32/shfldr_unixfs.c
@@ -1197,20 +1197,9 @@ static HRESULT WINAPI ShellFolder2_GetUIObjectOf(IShellFolder2* iface, HWND hwnd
     } else if (IsEqualIID(&IID_IDataObject, riid)) {
         *ppvOut = IDataObject_Constructor(hwndOwner, This->m_pidlLocation, apidl, cidl);
         return S_OK;
-    } else if (IsEqualIID(&IID_IExtractIconA, riid)) {
-        LPITEMIDLIST pidl;
+    } else if (IsEqualIID(&IID_IExtractIconA, riid) || IsEqualIID(&IID_IExtractIconW, riid)) {
         if (cidl != 1) return E_INVALIDARG;
-        pidl = ILCombine(This->m_pidlLocation, apidl[0]);
-        *ppvOut = IExtractIconA_Constructor(pidl);
-        SHFree(pidl);
-        return S_OK;
-    } else if (IsEqualIID(&IID_IExtractIconW, riid)) {
-        LPITEMIDLIST pidl;
-        if (cidl != 1) return E_INVALIDARG;
-        pidl = ILCombine(This->m_pidlLocation, apidl[0]);
-        *ppvOut = IExtractIconW_Constructor(pidl);
-        SHFree(pidl);
-        return S_OK;
+        return IExtractIconAW_Constructor(This->m_pidlLocation, apidl[0], riid, ppvOut);
     } else if (IsEqualIID(&IID_IDropTarget, riid)) {
         if (cidl != 1) return E_INVALIDARG;
         return IShellFolder2_BindToObject(iface, apidl[0], NULL, &IID_IDropTarget, ppvOut);
-- 
1.7.5.4




More information about the wine-patches mailing list