From b948aa332c2a604202c776043bd88d2d89207b49 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 13 Mar 2014 16:21:56 +0000 Subject: [PATCH] [RSHELL] * Fix some null dereferences. * Fix positioning of submenus of an horizontal menu toolbar. [BROWSEUI] * Fix some null dereferences. CORE-7586 svn path=/branches/shell-experiments/; revision=62492 --- base/shell/rshell/CMenuDeskBar.cpp | 2 -- base/shell/rshell/CMenuToolbars.cpp | 29 ++++++++++++++++++++--------- dll/win32/browseui/addressband.cpp | 12 ++++++++---- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/base/shell/rshell/CMenuDeskBar.cpp b/base/shell/rshell/CMenuDeskBar.cpp index 86a25c1b3aa..76abbcb2502 100644 --- a/base/shell/rshell/CMenuDeskBar.cpp +++ b/base/shell/rshell/CMenuDeskBar.cpp @@ -345,8 +345,6 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::Popup(POINTL *ppt, RECTL *prcExclude, MP y = rcWorkArea.bottom - cy; } - - this->SetWindowPos(HWND_TOPMOST, x, y, cx, cy, SWP_SHOWWINDOW); m_ShowFlags = dwFlags; diff --git a/base/shell/rshell/CMenuToolbars.cpp b/base/shell/rshell/CMenuToolbars.cpp index 9fb2ae62611..0fb1e5e07ff 100644 --- a/base/shell/rshell/CMenuToolbars.cpp +++ b/base/shell/rshell/CMenuToolbars.cpp @@ -492,9 +492,15 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child ClientToScreen(m_hwnd, &c); ClientToScreen(m_hwnd, &d); - POINTL pt = { b.x - 3, a.y - 3 }; + POINTL pt = { a.x, b.y }; RECTL rcl = { c.x, c.y, d.x, d.y }; + if(m_toolbarFlags & SMINIT_VERTICAL) + { + pt.x = b.x - 3; + pt.y = a.y - 3; + } + #if USE_SYSTEM_MENUSITE hr = CoCreateInstance(CLSID_MenuBandSite, NULL, @@ -830,13 +836,16 @@ CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) : } HRESULT CMenuStaticToolbar::GetMenu( - HMENU *phmenu, - HWND *phwnd, - DWORD *pdwFlags) + _Out_opt_ HMENU *phmenu, + _Out_opt_ HWND *phwnd, + _Out_opt_ DWORD *pdwFlags) { - *phmenu = m_hmenu; - *phwnd = NULL; - *pdwFlags = m_dwMenuFlags; + if (phmenu) + *phmenu = m_hmenu; + if (phwnd) + *phwnd = NULL; + if (pdwFlags) + *pdwFlags = m_dwMenuFlags; return S_OK; } @@ -977,7 +986,9 @@ HRESULT CMenuStaticToolbar::InternalHasSubMenu(INT uItem, INT index, DWORD_PTR d CMenuSFToolbar::CMenuSFToolbar(CMenuBand * menuBand) : CMenuToolbarBase(menuBand, TRUE), - m_shellFolder(NULL) + m_shellFolder(NULL), + m_idList(NULL), + m_hKey(NULL) { } @@ -1049,7 +1060,7 @@ HRESULT CMenuSFToolbar::OnDeletingButton(const NMTOOLBAR * tb) HRESULT CMenuSFToolbar::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags) { m_shellFolder = psf; - m_idList = pidlFolder; + m_idList = ILClone(pidlFolder); m_hKey = hKey; m_dwMenuFlags = dwFlags; return S_OK; diff --git a/dll/win32/browseui/addressband.cpp b/dll/win32/browseui/addressband.cpp index 0e5ab2e1852..29f04b4789d 100644 --- a/dll/win32/browseui/addressband.cpp +++ b/dll/win32/browseui/addressband.cpp @@ -311,10 +311,14 @@ HRESULT STDMETHODCALLTYPE CAddressBand::IsWindowOwner(HWND hWnd) CComPtr winEventHandler; HRESULT hResult; - hResult = fAddressEditBox->QueryInterface(IID_IWinEventHandler, reinterpret_cast(&winEventHandler)); - if (FAILED(hResult)) - return hResult; - return winEventHandler->IsWindowOwner(hWnd); + if (fAddressEditBox) + { + hResult = fAddressEditBox->QueryInterface(IID_IWinEventHandler, reinterpret_cast(&winEventHandler)); + if (FAILED(hResult)) + return hResult; + return winEventHandler->IsWindowOwner(hWnd); + } + return S_FALSE; } HRESULT STDMETHODCALLTYPE CAddressBand::FileSysChange(long param8, long paramC)