Fix memory leak when toggling to and from Dark Mode

Fix the memory leak due to icons of toolbar - they are not removed from ImageList while switching between dark/lite mode.

Fix #10957, close #10966
This commit is contained in:
Ashfaaq18 2021-12-29 19:35:10 +05:30 committed by Don Ho
parent c0989d472c
commit 79fa0abc8b
2 changed files with 10 additions and 0 deletions

View File

@ -99,6 +99,11 @@ void ToolBarIcons::reInit(int size)
ImageList_SetIconSize(getDefaultLstSetDM2(), size, size);
ImageList_SetIconSize(getDisableLstSetDM2(), size, size);
for (size_t i = 0; i < _iconListVector.size(); ++i)
{
_iconListVector[i].removeAll();
}
for (size_t i = 0, len = _tbiis.size(); i < len; ++i)
{
if (_tbiis[i]._defaultIcon != -1)

View File

@ -33,6 +33,11 @@ public :
void destroy() {
ImageList_Destroy(_hImglst);
};
void removeAll() {
ImageList_RemoveAll(_hImglst);
};
HIMAGELIST getHandle() const {return _hImglst;};
void addIcon(int iconID) const;
void addIcon(HICON hIcon) const;