Skip to content

Commit

Permalink
Remove explicit drop
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Apr 26, 2022
1 parent 5346625 commit 26ddd5d
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 @@ -168,11 +168,8 @@ fn change_window(
}
}
bevy_window::WindowCommand::Close => {
let window = winit_windows.remove_window(id);
// Close the window
drop(window);
// Since we borrow `windows` here to iterate through them, we can't mutate it here.
// Add it to the queue to solve this
// Since we have borrowed `windows` to iterate through them, we can't remove the window from it.
// Add the removal requests to a queue to solve this
removed_windows.push(id);
// No need to run any further commands - this drops the rest of the commands, although the `bevy_window::Window` will be dropped later anyway
break;
Expand All @@ -182,6 +179,9 @@ fn change_window(
}
if !removed_windows.is_empty() {
for id in removed_windows {
// Close the OS window. (The `Drop` impl actually closes the window)
let _ = winit_windows.remove_window(id);
// Clean up our own data structures
windows.remove(id);
window_close_events.send(WindowClosed { id });
}
Expand Down

0 comments on commit 26ddd5d

Please sign in to comment.