Skip to content

Commit c9deedb

Browse files
committed
Remove explicit drop
1 parent 2510dea commit c9deedb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/bevy_winit/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,8 @@ fn change_window(
168168
}
169169
}
170170
bevy_window::WindowCommand::Close => {
171-
let window = winit_windows.remove_window(id);
172-
// Close the window
173-
drop(window);
174-
// Since we borrow `windows` here to iterate through them, we can't mutate it here.
175-
// Add it to the queue to solve this
171+
// Since we have borrowed `windows` to iterate through them, we can't remove the window from it.
172+
// Add the removal requests to a queue to solve this
176173
removed_windows.push(id);
177174
// No need to run any further commands - this drops the rest of the commands, although the `bevy_window::Window` will be dropped later anyway
178175
break;
@@ -182,6 +179,9 @@ fn change_window(
182179
}
183180
if !removed_windows.is_empty() {
184181
for id in removed_windows {
182+
// Close the OS window. (The `Drop` impl actually closes the window)
183+
let _ = winit_windows.remove_window(id);
184+
// Clean up our own data structures
185185
windows.remove(id);
186186
window_close_events.send(WindowClosed { id });
187187
}

0 commit comments

Comments
 (0)