From 3c9e8eb969726317b3c52700d2a5005777740287 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Mon, 16 Dec 2024 12:39:30 +0400 Subject: [PATCH] avoid crash on exit --- examples/common/debug_render.rs | 4 ++-- examples/common/orbit_camera.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/common/debug_render.rs b/examples/common/debug_render.rs index 18e9b11..93c3fcc 100644 --- a/examples/common/debug_render.rs +++ b/examples/common/debug_render.rs @@ -35,13 +35,13 @@ fn display_debug_render_ui( mut settings: ResMut, ) { const TOOLTIP_MARGIN: f32 = 10.; - let ctx = egui_contexts.ctx_mut(); + let Some(egui_ctx) = egui_contexts.try_ctx_mut() else { return; }; Window::new("debug_render_ui") .anchor(Align2::RIGHT_TOP, egui::vec2(-TOOLTIP_MARGIN, TOOLTIP_MARGIN)) .title_bar(false) .auto_sized() .resizable(false) - .show(ctx, |ui| { + .show(egui_ctx, |ui| { macro_rules! checkbox { ($setting: ident, $desc: literal) => { let orig_value = settings.$setting > 0.; diff --git a/examples/common/orbit_camera.rs b/examples/common/orbit_camera.rs index 6141524..37adee5 100644 --- a/examples/common/orbit_camera.rs +++ b/examples/common/orbit_camera.rs @@ -82,7 +82,7 @@ fn apply_camera_controls( mut egui_contexts: EguiContexts, mut camera_query: Query<&mut OrbitCamera>, ) { - let egui_ctx = egui_contexts.ctx_mut(); + let Some(egui_ctx) = egui_contexts.try_ctx_mut() else { return; }; if egui_ctx.wants_pointer_input() { return; } enum MyEvent {