Skip to content

Commit bb475cf

Browse files
authored
Fix: Resolved the memory leak when setting the icon multiple times on windows (#76)
1 parent f62bdd7 commit bb475cf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/tray_manager/windows/tray_manager_plugin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ void TrayManagerPlugin::SetIcon(
234234

235235
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
236236

237+
if (nid.hIcon != nullptr) {
238+
DestroyIcon(nid.hIcon);
239+
}
240+
237241
nid.hIcon = static_cast<HICON>(
238242
LoadImage(nullptr, (LPCWSTR)(converter.from_bytes(iconPath).c_str()),
239243
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),

0 commit comments

Comments
 (0)