win32: drop application handler on WM_ENDSESSION#4425
win32: drop application handler on WM_ENDSESSION#4425Legend-Master wants to merge 4 commits intorust-windowing:masterfrom
WM_ENDSESSION#4425Conversation
| } | ||
| #[cfg(windows_platform)] | ||
| { | ||
| self.event_loop.run_app_on_demand(app) |
There was a problem hiding this comment.
I made this a separate call on Windows to pass in the ownership of app instead of &mut app so we can drop it later, but I am not exactly sure why it was done like this
let result = self.event_loop.run_app_on_demand(&mut app);
// SAFETY: unsure that the state is dropped before the exit from the event loop.
drop(app);
resultThere was a problem hiding this comment.
It was done like that, because run_on_demand borrows, so you can not drop from it, since you'll be dropping & more likely, which won't work, but in run_app it's :static thus the actual value is being dropped.
There was a problem hiding this comment.
I'm pretty sure that it's wrong too? run_app_on_demand doesn't borrow, and passing a reference prevents it from Drop-ing when e.g. NSApplicationDelegate is terminated.
There was a problem hiding this comment.
So should I change this for all platforms?
| if wparam == true as usize { | ||
| // Sent from Restart Manager | ||
| // > https://learn.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications | ||
| if lparam == ENDSESSION_CLOSEAPP as isize { |
There was a problem hiding this comment.
To help testing this, you could try https://github.com/Legend-Master/windows-restart-manager-test, replace let file_path = HSTRING::from(r""); to the executable path you want to terminate, and cargo run
changelogmodule if knowledge of this change could be valuable to usersReference tao PR: tauri-apps/tao#1126
Implemented the solution talked in #4149 (comment)