[macos] Remove Window from EventsLoop's Window list on close and drop

Previously, a Window was only removed from the list when dropped.
This commit is contained in:
mitchmindtree 2017-03-19 19:20:38 +11:00
parent 41e7572147
commit 27bd796c2a
2 changed files with 19 additions and 5 deletions

View file

@ -217,6 +217,18 @@ impl EventsLoop {
}
}
// Removes the window with the given `Id` from the `windows` list.
//
// This is called when a window is either `Closed` or `Drop`ped.
pub fn find_and_remove_window(&self, id: super::window::Id) {
if let Ok(mut windows) = self.windows.lock() {
windows.retain(|w| match w.upgrade() {
Some(w) => w.id() != id,
None => true,
});
}
}
fn call_user_callback_with_pending_events(&self) {
loop {
let event = match self.pending_events.lock().unwrap().pop_front() {