Skip to content

Commit

Permalink
Don't deliver any new events once exiting.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed May 7, 2024
1 parent a8acdb3 commit 75c33d4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ pub fn winit_runner(mut app: App) -> AppExit {
let mut winit_events = Vec::default();
// set up the event loop
let event_handler = move |event, event_loop: &EventLoopWindowTarget<UserEvent>| {
// The event loop is in the process of exiting, so don't deliver any new events
if event_loop.exiting() {
return;
}

handle_winit_event(
&mut app,
&mut runner_state,
Expand Down Expand Up @@ -776,11 +781,6 @@ fn handle_winit_event(
}

if let Some(app_exit) = app.should_exit() {
// The event loop is in the process of exiting, but we might still be processing events.
if event_loop.exiting() {
return;
}

if let Err(err) = exit_notify.try_send(app_exit) {
error!("Failed to send a app exit notification! This is a bug. Reason: {err}");
};
Expand Down

0 comments on commit 75c33d4

Please sign in to comment.