Prevent an additional world update after all windows have closed on Windows (#18175)
# Objective The fix in #18105 includes a check for running headless, but this allows for an extra world update during shutdown. This commit checks if the `AppExit` event has been recorded and prevents the additional world update. ### Before ``` 2025-03-06T03:11:59.999679Z INFO bevy_window::system: No windows are open, exiting 2025-03-06T03:12:00.001942Z INFO bevy_winit::system: Closing window 0v1 2025-03-06T03:12:00.012691Z INFO bevy_window::system: No windows are open, exiting ``` ### After ``` 2025-03-06T03:18:45.552243Z INFO bevy_window::system: No windows are open, exiting 2025-03-06T03:18:45.554119Z INFO bevy_winit::system: Closing window 0v1 ``` ## Testing Ran `window` examples - `monitor_info` continues to run after all windows are closed (it has `ExitCondition::DontExit`) - `window_settings` invisible window creation works as expected - `multiple_windows` exits after both windows are closed with a single exit message
This commit is contained in:
parent
d8f3eb3e8b
commit
19ee692f96
@ -491,11 +491,12 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
|
|||||||
{
|
{
|
||||||
let winit_windows = self.world().non_send_resource::<WinitWindows>();
|
let winit_windows = self.world().non_send_resource::<WinitWindows>();
|
||||||
let headless = winit_windows.windows.is_empty();
|
let headless = winit_windows.windows.is_empty();
|
||||||
|
let exiting = self.app_exit.is_some();
|
||||||
let all_invisible = winit_windows
|
let all_invisible = winit_windows
|
||||||
.windows
|
.windows
|
||||||
.iter()
|
.iter()
|
||||||
.all(|(_, w)| !w.is_visible().unwrap_or(false));
|
.all(|(_, w)| !w.is_visible().unwrap_or(false));
|
||||||
if self.startup_forced_updates > 0 || headless || all_invisible {
|
if !exiting && (self.startup_forced_updates > 0 || headless || all_invisible) {
|
||||||
self.redraw_requested(event_loop);
|
self.redraw_requested(event_loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user