Skip to content

Commit

Permalink
fix(windows): leak when updating tray icon or tooltip (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lej77 authored Jul 3, 2023
1 parent 8f361f0 commit e9875fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-fix-leak-on-update-tray.md
Original file line number Diff line number Diff line change
@@ -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`.
4 changes: 2 additions & 2 deletions src/platform_impl/windows/system_tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e9875fe

Please sign in to comment.