Avoid leaking Windows by storing Weak pointers in EventsLoop

This commit is contained in:
mitchmindtree 2017-03-19 18:19:24 +11:00
parent c6968782b1
commit 4b39f81621
3 changed files with 19 additions and 10 deletions

View file

@ -174,7 +174,10 @@ impl Drop for Window {
let id = self.id();
if let Some(ev) = self.delegate.state.events_loop.upgrade() {
let mut windows = ev.windows.lock().unwrap();
windows.retain(|w| w.id() != id)
windows.retain(|w| match w.upgrade() {
Some(w) => w.id() != id,
None => true,
})
}
}
}