diff --git a/.changes/windows-fix-leak-on-update-tray.md b/.changes/windows-fix-leak-on-update-tray.md new file mode 100644 index 000000000..7c1aacae9 --- /dev/null +++ b/.changes/windows-fix-leak-on-update-tray.md @@ -0,0 +1,5 @@ +--- +"tao": "patch" +--- + +On Windows, fix leak of `tao::system_tray::Icon` when calling `tao::system_tray::SystemTray::set_icon` and leak of `String` when calling `tao::system_tray::SystemTray::set_tooltip`. diff --git a/src/platform_impl/windows/system_tray.rs b/src/platform_impl/windows/system_tray.rs index 0c46c2951..f44c5184c 100644 --- a/src/platform_impl/windows/system_tray.rs +++ b/src/platform_impl/windows/system_tray.rs @@ -274,12 +274,12 @@ unsafe extern "system" fn tray_subclass_proc( if msg == WM_USER_UPDATE_TRAYICON { let icon = wparam.0 as *mut Icon; - subclass_input.icon = (*icon).clone(); + subclass_input.icon = *Box::from_raw(icon); } if msg == WM_USER_UPDATE_TOOLTIP { let tooltip = wparam.0 as *mut String; - subclass_input.tooltip = Some((*tooltip).clone()); + subclass_input.tooltip = Some(*Box::from_raw(tooltip)); } if msg == *S_U_TASKBAR_RESTART {