Module: wine Branch: master Commit: 3efda60ef650af52d6e3aa28e238cf578a9f9063 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3efda60ef650af52d6e3aa28e2...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Jan 11 04:39:24 2012 +0300
shell32: Avoid pointer casts when background menu is created.
---
dlls/shell32/shell32_main.h | 2 +- dlls/shell32/shfldr_desktop.c | 6 ++++-- dlls/shell32/shlview.c | 10 ++++------ dlls/shell32/shlview_cmenu.c | 11 ++++++++--- 4 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index 4b883fd..3b0fb83 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -79,7 +79,7 @@ LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT, const FORMATETC []) DECLSPEC_HI
LPCLASSFACTORY IClassFactory_Constructor(REFCLSID) DECLSPEC_HIDDEN; IContextMenu2 * ItemMenu_Constructor(IShellFolder*, LPCITEMIDLIST, const LPCITEMIDLIST*, UINT) DECLSPEC_HIDDEN; -IContextMenu2 * BackgroundMenu_Constructor(IShellFolder*, BOOL) DECLSPEC_HIDDEN; +HRESULT BackgroundMenu_Constructor(IShellFolder*, BOOL, REFIID, void**) DECLSPEC_HIDDEN; LPSHELLVIEW IShellView_Constructor(LPSHELLFOLDER) DECLSPEC_HIDDEN;
HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) DECLSPEC_HIDDEN; diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index 202a793..ec9ba63 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -530,10 +530,12 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, if (IsEqualIID (riid, &IID_IContextMenu)) { if (cidl > 0) + { pObj = (LPUNKNOWN) ItemMenu_Constructor( (IShellFolder *) iface, This->pidlRoot, apidl, cidl); + hr = S_OK; + } else - pObj = (LPUNKNOWN) BackgroundMenu_Constructor( (IShellFolder *) iface, TRUE); - hr = S_OK; + return BackgroundMenu_Constructor((IShellFolder*)iface, TRUE, riid, ppvOut); } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) { diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c index 44cbcb6..efd6e0f 100644 --- a/dlls/shell32/shlview.c +++ b/dlls/shell32/shlview.c @@ -1018,7 +1018,6 @@ static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL BOOL fExplore = FALSE; HWND hwndTree = 0; LPCONTEXTMENU pContextMenu = NULL; - IContextMenu2 *pCM = NULL; CMINVOKECOMMANDINFO cmi;
TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault); @@ -1093,9 +1092,11 @@ static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL } else /* background context menu */ { + IContextMenu2 *pCM; + hMenu = CreatePopupMenu();
- pCM = BackgroundMenu_Constructor(This->pSFParent, FALSE); + BackgroundMenu_Constructor(This->pSFParent, FALSE, &IID_IContextMenu2, (void**)&pCM); IContextMenu2_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL); @@ -2049,10 +2050,7 @@ static HRESULT WINAPI IShellView_fnGetItemObject(IShellView2 *iface, UINT uItem, case SVGIO_BACKGROUND:
if (IsEqualIID(&IID_IContextMenu, riid)) - { - *ppvOut = BackgroundMenu_Constructor(This->pSFParent, FALSE); - hr = S_OK; - } + return BackgroundMenu_Constructor(This->pSFParent, FALSE, riid, ppvOut); else FIXME("unsupported interface requested %s\n", debugstr_guid(riid));
diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c index 31db01e..7833efe 100644 --- a/dlls/shell32/shlview_cmenu.c +++ b/dlls/shell32/shlview_cmenu.c @@ -877,11 +877,14 @@ static const IContextMenu3Vtbl BackgroundContextMenuVtbl = ContextMenu_HandleMenuMsg2 };
-IContextMenu2 *BackgroundMenu_Constructor(IShellFolder *parent, BOOL desktop) +HRESULT BackgroundMenu_Constructor(IShellFolder *parent, BOOL desktop, REFIID riid, void **pObj) { ContextMenu *This; + HRESULT hr;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); + if (!This) return E_OUTOFMEMORY; + This->IContextMenu3_iface.lpVtbl = &BackgroundContextMenuVtbl; This->ref = 1; This->parent = parent; @@ -895,6 +898,8 @@ IContextMenu2 *BackgroundMenu_Constructor(IShellFolder *parent, BOOL desktop) This->desktop = desktop; if (parent) IShellFolder_AddRef(parent);
- TRACE("(%p)\n", This); - return (IContextMenu2*)&This->IContextMenu3_iface; + hr = IContextMenu3_QueryInterface(&This->IContextMenu3_iface, riid, pObj); + IContextMenu3_Release(&This->IContextMenu3_iface); + + return hr; }