From d07a1dc09a02f9693c5c324610cf28972b39bcf5 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Sat, 25 Oct 2014 15:44:11 +0000 Subject: [PATCH] [EXPLORER-NEW] * Fix HMENU leak. [BROWSEUI] * Work around for WM_SETICON not properly returning the old HICON. [SHELL32] * Fix HICON leak. * Nitpick. [WIN32K] * Do not refcount the menus improperly. svn path=/branches/shell-experiments/; revision=64986 --- base/shell/explorer-new/traywnd.c | 2 ++ dll/win32/browseui/shellbrowser.cpp | 11 +++++++---- dll/win32/shell32/newmenu.cpp | 3 +++ dll/win32/shell32/shlview.cpp | 2 +- win32ss/user/ntuser/menu.c | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/base/shell/explorer-new/traywnd.c b/base/shell/explorer-new/traywnd.c index 3e04bf42ee6..d05ae391fda 100644 --- a/base/shell/explorer-new/traywnd.c +++ b/base/shell/explorer-new/traywnd.c @@ -1023,6 +1023,8 @@ ITrayWindowImpl_TrackCtxMenu(IN OUT ITrayWindowImpl *This, cmdId, pcmContext, Context); + + DestroyMenu(hPopup); } return cmdId; diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index ea89e17ea50..c12143e143e 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -1078,15 +1078,18 @@ HRESULT CShellBrowser::BrowseToPath(IShellFolder *newShellFolder, HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0); HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0); - HICON oldSmall = (HICON)SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast(icSmall)); - HICON oldLarge = (HICON)SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast(icLarge)); + /* Hack to make it possible to release the old icons */ + /* Something seems to go wrong with WM_SETICON */ + HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0); + HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0); + + SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast(icSmall)); + SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast(icLarge)); DestroyIcon(oldSmall); DestroyIcon(oldLarge); } - // TODO: Update the window icon - FireCommandStateChangeAll(); hResult = UpdateForwardBackState(); return S_OK; diff --git a/dll/win32/shell32/newmenu.cpp b/dll/win32/shell32/newmenu.cpp index 5b1668176e9..db71220fe10 100644 --- a/dll/win32/shell32/newmenu.cpp +++ b/dll/win32/shell32/newmenu.cpp @@ -179,7 +179,10 @@ CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPCWSTR pwszExt) pNewItem->pwszExt = _wcsdup(pwszExt); pNewItem->pwszDesc = _wcsdup(fi.szTypeName); if (fi.hIcon) + { pNewItem->hBitmap = IconToBitmap(fi.hIcon); + DestroyIcon(fi.hIcon); + } return pNewItem; } diff --git a/dll/win32/shell32/shlview.cpp b/dll/win32/shell32/shlview.cpp index b00e973227f..54018e7f35e 100644 --- a/dll/win32/shell32/shlview.cpp +++ b/dll/win32/shell32/shlview.cpp @@ -984,7 +984,7 @@ LRESULT CDefView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl SHFree((LPITEMIDLIST)ntreg.pidl); } - m_hAccel = LoadAcceleratorsA(shell32_hInstance, MAKEINTRESOURCEA( IDA_SHELLVIEW)); + m_hAccel = LoadAcceleratorsW(shell32_hInstance, MAKEINTRESOURCEW(IDA_SHELLVIEW)); return S_OK; } diff --git a/win32ss/user/ntuser/menu.c b/win32ss/user/ntuser/menu.c index 9cd09171564..bb93bfa937f 100644 --- a/win32ss/user/ntuser/menu.c +++ b/win32ss/user/ntuser/menu.c @@ -1653,7 +1653,7 @@ PMENU FASTCALL MENU_GetSystemMenu(PWND Window, PMENU Popup) { return NULL; } - SysMenu = IntGetMenuObject(hSysMenu); + SysMenu = UserGetMenuObject(hSysMenu); if (NULL == SysMenu) { UserDestroyMenu(hSysMenu); @@ -1684,7 +1684,7 @@ PMENU FASTCALL MENU_GetSystemMenu(PWND Window, PMENU Popup) UserDestroyMenu(hSysMenu); return NULL; } - Menu = IntGetMenuObject(hNewMenu); + Menu = UserGetMenuObject(hNewMenu); if (!Menu) { IntReleaseMenuObject(SysMenu); -- 2.17.1