Produce window::Event::Closed only if window exists

This commit is contained in:
Héctor Ramón Jiménez 2024-08-15 02:11:17 +02:00
parent 7c2abc9b8b
commit 9b99b932bc
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F

View file

@ -1223,14 +1223,16 @@ fn run_action<P, C>(
*is_window_opening = true; *is_window_opening = true;
} }
window::Action::Close(id) => { window::Action::Close(id) => {
let _ = window_manager.remove(id); let window = window_manager.remove(id);
let _ = ui_caches.remove(&id); let _ = ui_caches.remove(&id);
if window.is_some() {
events.push(( events.push((
id, id,
core::Event::Window(core::window::Event::Closed), core::Event::Window(core::window::Event::Closed),
)); ));
} }
}
window::Action::GetOldest(channel) => { window::Action::GetOldest(channel) => {
let id = let id =
window_manager.iter_mut().next().map(|(id, _window)| id); window_manager.iter_mut().next().map(|(id, _window)| id);