Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/wm-endsession-exit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
tao: patch
---

Exits the process on receiving `WM_ENDSESSION` message, this fixes the `cannot move state from Destroyed` crash after receiving the message from Restart Manager
8 changes: 7 additions & 1 deletion src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2414,8 +2414,14 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
// and we don't need to handle that case since we didn't do anything prior in response to `WM_QUERYENDSESSION`
if wparam.0 == TRUE.0 as usize {
subclass_input.event_loop_runner.loop_destroyed();
// `WM_ENDSESSION` can be sent by Windows during shutdown or by Restart Manager
//
// - From Windows shutdown: Windows will shut us down after we return `0` here
// - From Restart Manager: Restart Manager only sends the message but will wait for us to shutdown ourselves
//
// So, we call `exit` here directly to align this behavior
std::process::exit(0);
}
// Note: after we return 0 here, Windows will shut us down
LRESULT(0)
}

Expand Down
Loading