-
Notifications
You must be signed in to change notification settings - Fork 1.1k
win32: drop application handler on WM_ENDSESSION
#4425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| } | ||
| #[cfg(windows_platform)] | ||
| { | ||
| self.event_loop.run_app_on_demand(app) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)