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

Detlef Riekenberg wine.dev at web.de
Sun May 20 10:47:43 CDT 2012


The api is now similar to the IQueryInfo_Constructor

--
By by ... Detlef
---
 dlls/shell32/cpanelfolder.c     |   10 +-------
 dlls/shell32/folders.c          |   40 +++++++++++++++++++-------------------
 dlls/shell32/shell32_main.h     |    3 +-
 dlls/shell32/shfldr_desktop.c   |   10 +-------
 dlls/shell32/shfldr_fs.c        |   10 +-------
 dlls/shell32/shfldr_mycomp.c    |   10 +-------
 dlls/shell32/shfldr_netplaces.c |   11 +--------
 dlls/shell32/shfldr_unixfs.c    |   12 +---------
 8 files changed, 33 insertions(+), 73 deletions(-)

diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c
index 1229e47..b370850 100644
--- a/dlls/shell32/cpanelfolder.c
+++ b/dlls/shell32/cpanelfolder.c
@@ -605,15 +605,9 @@ static HRESULT WINAPI ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 *iface, HWN
 	    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;
+            return IExtractIconAW_Constructor(This->pidlRoot, apidl[0], FALSE, ppvOut);
 	} 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], TRUE, 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 2d38637..4b45f03 100644
--- a/dlls/shell32/folders.c
+++ b/dlls/shell32/folders.c
@@ -544,37 +544,37 @@ static const IPersistFileVtbl pfvt =
 	(void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
 };
 
-static IExtractIconWImpl *extracticon_create(LPCITEMIDLIST pidl)
+
+HRESULT IExtractIconAW_Constructor(LPCITEMIDLIST root, LPCITEMIDLIST item, BOOL is_unicode, void ** ppvOut)
 {
-    IExtractIconWImpl *ei;
+    IExtractIconWImpl *ei = HeapAlloc(GetProcessHeap(), 0, sizeof(IExtractIconWImpl));
+    LPITEMIDLIST pidl = ILCombine(root, item);
 
-    TRACE("%p\n", pidl);
+    if (!pidl || !ei) {
+        SHFree(pidl);
+        HeapFree(GetProcessHeap(), 0, 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);
-
-    return &ei->IExtractIconW_iface;
-}
+    SHFree(pidl);
+    if (!ei->pidl) {
+        HeapFree(GetProcessHeap(), 0, ei);
+        return E_OUTOFMEMORY;
+    }
 
-IExtractIconA *IExtractIconA_Constructor(LPCITEMIDLIST pidl)
-{
-    IExtractIconWImpl *ei = extracticon_create(pidl);
+    if (is_unicode)
+        *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..18c8dd7 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, BOOL, 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..40b3957 100644
--- a/dlls/shell32/shfldr_desktop.c
+++ b/dlls/shell32/shfldr_desktop.c
@@ -542,17 +542,11 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
     }
     else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
     {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
+        return IExtractIconAW_Constructor(This->pidlRoot, apidl[0], FALSE, ppvOut);
     }
     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], TRUE, 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..1113409 100644
--- a/dlls/shell32/shfldr_fs.c
+++ b/dlls/shell32/shfldr_fs.c
@@ -750,15 +750,9 @@ IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface,
              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;
+            return IExtractIconAW_Constructor(This->pidlRoot, apidl[0], FALSE, ppvOut);
         } 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], TRUE, 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..ee98b4d 100644
--- a/dlls/shell32/shfldr_mycomp.c
+++ b/dlls/shell32/shfldr_mycomp.c
@@ -542,17 +542,11 @@ static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
     }
     else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
     {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
+        return IExtractIconAW_Constructor(This->pidlRoot, apidl[0], FALSE, ppvOut);
     }
     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], TRUE, 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..c6331cb 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;
 
@@ -435,17 +434,11 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface,
     }
     else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
     {
-        pidl = ILCombine (This->pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
-        SHFree (pidl);
-        hr = S_OK;
+        return IExtractIconAW_Constructor(This->pidlRoot, apidl[0], FALSE, ppvOut);
     }
     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], TRUE, 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..d495946 100644
--- a/dlls/shell32/shfldr_unixfs.c
+++ b/dlls/shell32/shfldr_unixfs.c
@@ -1198,19 +1198,11 @@ static HRESULT WINAPI ShellFolder2_GetUIObjectOf(IShellFolder2* iface, HWND hwnd
         *ppvOut = IDataObject_Constructor(hwndOwner, This->m_pidlLocation, apidl, cidl);
         return S_OK;
     } else if (IsEqualIID(&IID_IExtractIconA, riid)) {
-        LPITEMIDLIST pidl;
         if (cidl != 1) return E_INVALIDARG;
-        pidl = ILCombine(This->m_pidlLocation, apidl[0]);
-        *ppvOut = IExtractIconA_Constructor(pidl);
-        SHFree(pidl);
-        return S_OK;
+        return IExtractIconAW_Constructor(This->m_pidlLocation, apidl[0], FALSE, ppvOut);
     } 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], TRUE, 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