Fix crash when closing windows

This commit is contained in:
Nathan Sobo
2021-05-05 11:34:49 -06:00
parent f7d8b6b4c0
commit 3f844bc953
4 changed files with 42 additions and 1 deletions
+6
View File
@@ -16,6 +16,7 @@ pub struct Window {
current_scene: Option<crate::Scene>,
event_handlers: Vec<Box<dyn FnMut(super::Event)>>,
resize_handlers: Vec<Box<dyn FnMut(&mut dyn super::WindowContext)>>,
close_handlers: Vec<Box<dyn FnOnce()>>,
}
impl Platform {
@@ -92,6 +93,7 @@ impl Window {
size,
event_handlers: Vec::new(),
resize_handlers: Vec::new(),
close_handlers: Vec::new(),
scale_factor: 1.0,
current_scene: None,
}
@@ -130,6 +132,10 @@ impl super::Window for Window {
fn on_resize(&mut self, callback: Box<dyn FnMut(&mut dyn super::WindowContext)>) {
self.resize_handlers.push(callback);
}
fn on_close(&mut self, callback: Box<dyn FnOnce()>) {
self.close_handlers.push(callback);
}
}
pub fn platform() -> impl super::Platform {