From 79fa0abc8b5c9ff74f24780050a73186fae5b6a7 Mon Sep 17 00:00:00 2001 From: Ashfaaq18 Date: Wed, 29 Dec 2021 19:35:10 +0530 Subject: [PATCH] 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 --- PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp | 5 +++++ PowerEditor/src/WinControls/ImageListSet/ImageListSet.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp index bd7011844..52b4f2b42 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp @@ -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) diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h index 9b29b77cf..ae1fc2437 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h @@ -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;