Clean up WinitWindows::remove_window (#12749)
# Objective
- Avoid unbounded HashMap growth for opening/closing windows.
## Solution
- Remove map entry in `WinitWindows::remove_window`.
## Migration Guide
- `WinitWindows::get_window_entity` now returns `None` after a window is
closed, instead of a dead entity.
---
## Comments
The comment this PR replaces was added in
https://github.com/bevyengine/bevy/pull/3575. Since `get_window_entity`
now returns an `Entity` instead of a `WindowId`, this no longer seems
useful. Note that `get_window_entity` is only used
[here](56bcbb0975/crates/bevy_winit/src/lib.rs (L436)
),
immediately followed by a warning if the entity returned doesn't exist.
This commit is contained in:
parent
c223fbb4c8
commit
c971b45361
@ -281,7 +281,7 @@ impl WinitWindows {
|
||||
/// This should mostly just be called when the window is closing.
|
||||
pub fn remove_window(&mut self, entity: Entity) -> Option<winit::window::Window> {
|
||||
let winit_id = self.entity_to_winit.remove(&entity)?;
|
||||
// Don't remove from `winit_to_window_id` so we know the window used to exist.
|
||||
self.winit_to_entity.remove(&winit_id);
|
||||
self.windows.remove(&winit_id)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user