Author: gadamopoulos
Date: Mon May 1 13:43:22 2017
New Revision: 74441
URL:
http://svn.reactos.org/svn/reactos?rev=74441&view=rev
Log:
[BROWSEUI] Don't leak the image lists created by CAddressBand and CToolsBand.
Modified:
trunk/reactos/dll/win32/browseui/addressband.cpp
trunk/reactos/dll/win32/browseui/addressband.h
trunk/reactos/dll/win32/browseui/toolsband.cpp
Modified: trunk/reactos/dll/win32/browseui/addressband.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/address…
==============================================================================
--- trunk/reactos/dll/win32/browseui/addressband.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/addressband.cpp [iso-8859-1] Mon May 1 13:43:22
2017
@@ -205,6 +205,12 @@
if (fAddressEditBox) fAddressEditBox.Release();
if (fSite) fSite.Release();
+ if (m_himlNormal)
+ ImageList_Destroy(m_himlNormal);
+
+ if (m_himlHot)
+ ImageList_Destroy(m_himlHot);
+
return S_OK;
}
@@ -521,15 +527,12 @@
void CAddressBand::CreateGoButton()
{
const TBBUTTON buttonInfo [] = { { 0, 1, TBSTATE_ENABLED, 0 } };
- HIMAGELIST normalImagelist;
- HIMAGELIST hotImageList;
HINSTANCE shellInstance;
-
shellInstance = GetModuleHandle(_T("shell32.dll"));
- normalImagelist = ImageList_LoadImageW(shellInstance,
MAKEINTRESOURCE(IDB_GOBUTTON_NORMAL),
+ m_himlNormal = ImageList_LoadImageW(shellInstance,
MAKEINTRESOURCE(IDB_GOBUTTON_NORMAL),
20, 0, RGB(255, 0, 255), IMAGE_BITMAP,
LR_CREATEDIBSECTION);
- hotImageList = ImageList_LoadImageW(shellInstance,
MAKEINTRESOURCE(IDB_GOBUTTON_HOT),
+ m_himlHot = ImageList_LoadImageW(shellInstance, MAKEINTRESOURCE(IDB_GOBUTTON_HOT),
20, 0, RGB(255, 0, 255), IMAGE_BITMAP,
LR_CREATEDIBSECTION);
fGoButton = CreateWindowEx(WS_EX_TOOLWINDOW, TOOLBARCLASSNAMEW, 0, WS_CHILD |
WS_CLIPSIBLINGS |
@@ -538,10 +541,10 @@
0, 0, 0, 0, m_hWnd, NULL,
_AtlBaseModule.GetModuleInstance(), NULL);
SendMessage(fGoButton, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessage(fGoButton, TB_SETMAXTEXTROWS, 1, 0);
- if (normalImagelist)
- SendMessage(fGoButton, TB_SETIMAGELIST, 0,
reinterpret_cast<LPARAM>(normalImagelist));
- if (hotImageList)
- SendMessage(fGoButton, TB_SETHOTIMAGELIST, 0,
reinterpret_cast<LPARAM>(hotImageList));
+ if (m_himlNormal)
+ SendMessage(fGoButton, TB_SETIMAGELIST, 0,
reinterpret_cast<LPARAM>(m_himlNormal));
+ if (m_himlHot)
+ SendMessage(fGoButton, TB_SETHOTIMAGELIST, 0,
reinterpret_cast<LPARAM>(m_himlHot));
SendMessage(fGoButton, TB_ADDSTRINGW,
reinterpret_cast<WPARAM>(_AtlBaseModule.GetResourceInstance()),
IDS_GOBUTTONLABEL);
SendMessage(fGoButton, TB_ADDBUTTONSW, 1, (LPARAM) &buttonInfo);
Modified: trunk/reactos/dll/win32/browseui/addressband.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/address…
==============================================================================
--- trunk/reactos/dll/win32/browseui/addressband.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/addressband.h [iso-8859-1] Mon May 1 13:43:22 2017
@@ -41,6 +41,9 @@
HWND fGoButton;
HWND fComboBox;
bool fGoButtonShown;
+ HIMAGELIST m_himlNormal;
+ HIMAGELIST m_himlHot;
+
public:
CAddressBand();
virtual ~CAddressBand();
Modified: trunk/reactos/dll/win32/browseui/toolsband.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/toolsba…
==============================================================================
--- trunk/reactos/dll/win32/browseui/toolsband.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/toolsband.cpp [iso-8859-1] Mon May 1 13:43:22 2017
@@ -40,6 +40,8 @@
CComPtr<IDockingWindowSite> fDockSite;
GUID fExecCommandCategory;
CComPtr<IOleCommandTarget> fExecCommandTarget;
+ HIMAGELIST m_himlNormal;
+ HIMAGELIST m_himlHot;
public:
CToolsBand();
virtual ~CToolsBand();
@@ -294,36 +296,16 @@
SendMessage(TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS |
TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS);
HINSTANCE shell32Instance = GetModuleHandle(_T("shell32.dll"));
- HBITMAP imgNormal = reinterpret_cast<HBITMAP>(
- LoadImage(shell32Instance, MAKEINTRESOURCE(214),
- IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION));
-
- HBITMAP imgHot = reinterpret_cast<HBITMAP>(
- LoadImage(shell32Instance, MAKEINTRESOURCE(215),
- IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION));
-
- if (imgNormal && imgHot)
- {
- BITMAP bitmapInfo;
- GetObjectW(imgNormal, sizeof(bitmapInfo), &bitmapInfo);
- HIMAGELIST himlNormal = ImageList_Create(bitmapInfo.bmHeight,
bitmapInfo.bmHeight, ILC_COLOR32, 4, 4);
- ImageList_Add(himlNormal, imgNormal, NULL);
-
- GetObjectW(imgHot, sizeof(bitmapInfo), &bitmapInfo);
- HIMAGELIST himlHot = ImageList_Create(bitmapInfo.bmHeight, bitmapInfo.bmHeight,
ILC_COLOR32, 4, 4);
- ImageList_Add(himlHot, imgHot, NULL);
-
- SendMessage(TB_SETIMAGELIST, 0, (LPARAM) himlNormal);
- SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM) himlHot);
- }
-
+ m_himlNormal = ImageList_LoadImageW(shell32Instance, MAKEINTRESOURCE(214),
+ 0, 0, RGB(255, 0, 255), IMAGE_BITMAP,
LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
+
+ m_himlHot = ImageList_LoadImageW(shell32Instance, MAKEINTRESOURCE(215),
+ 0, 0, RGB(255, 0, 255), IMAGE_BITMAP,
LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
+
+ SendMessage(TB_SETIMAGELIST, 0, (LPARAM) m_himlNormal);
+ SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM) m_himlHot);
SendMessage(TB_ADDBUTTONSW, numShownButtons, (LPARAM)&tbButtonsAdd);
- if (imgNormal)
- DeleteObject(imgNormal);
- if (imgHot)
- DeleteObject(imgHot);
-
return hResult;
}
@@ -344,7 +326,6 @@
HRESULT STDMETHODCALLTYPE CToolsBand::ContextSensitiveHelp(BOOL fEnterMode)
{
-
return E_NOTIMPL;
}
@@ -357,7 +338,14 @@
m_hWnd = NULL;
- if (fDockSite) fDockSite.Release();
+ if (fDockSite)
+ fDockSite.Release();
+
+ if (m_himlNormal)
+ ImageList_Destroy(m_himlNormal);
+
+ if (m_himlHot)
+ ImageList_Destroy(m_himlHot);
return S_OK;
}