handle panics in renderer somewhat more gracefully

macos-click-through
Keith Simmons 5 years ago
parent e72c8959f1
commit d0941cef2e

@ -171,11 +171,17 @@ pub fn ui_loop() {
let frame_start = Instant::now();
if REDRAW_SCHEDULER.should_draw() {
if let Err(err) = panic::catch_unwind(|| {
skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| {
if renderer.draw(canvas, coordinate_system_helper) {
handle_new_grid_size(window.inner_size(), &renderer)
}
}).ok();
}) {
println!("Render failed. Closing app");
*control_flow = ControlFlow::Exit;
return;
}
}
*control_flow = ControlFlow::WaitUntil(frame_start + Duration::from_secs_f32(1.0 / 60.0));

Loading…
Cancel
Save