Skip to content

Conversation

@Legend-Master
Copy link
Contributor

@Legend-Master Legend-Master commented Nov 25, 2025

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

Reference tao PR: tauri-apps/tao#1126
Implemented the solution talked in #4149 (comment)

}
#[cfg(windows_platform)]
{
self.event_loop.run_app_on_demand(app)
Copy link
Contributor Author

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);
result

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

@Legend-Master Legend-Master marked this pull request as ready for review November 25, 2025 01:55
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 {
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants