diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 4409c129..eeb7d485 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -562,24 +562,26 @@ impl EpiIntegration { pub fn maybe_autosave(&mut self, app: &mut dyn epi::App, window: &winit::window::Window) { let now = std::time::Instant::now(); if now - self.last_auto_save > app.auto_save_interval() { - self.save(app, window); + self.save(app, Some(window)); self.last_auto_save = now; } } #[allow(clippy::unused_self)] - pub fn save(&mut self, _app: &mut dyn epi::App, _window: &winit::window::Window) { + pub fn save(&mut self, _app: &mut dyn epi::App, _window: Option<&winit::window::Window>) { #[cfg(feature = "persistence")] if let Some(storage) = self.frame.storage_mut() { crate::profile_function!(); - if _app.persist_native_window() { - crate::profile_scope!("native_window"); - epi::set_value( - storage, - STORAGE_WINDOW_KEY, - &WindowSettings::from_display(_window), - ); + if let Some(window) = _window { + if _app.persist_native_window() { + crate::profile_scope!("native_window"); + epi::set_value( + storage, + STORAGE_WINDOW_KEY, + &WindowSettings::from_display(window), + ); + } } if _app.persist_egui_memory() { crate::profile_scope!("egui_memory"); diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 7771265a..3b4cc5c4 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -801,7 +801,7 @@ mod glow_integration { if let Some(mut running) = self.running.take() { running .integration - .save(running.app.as_mut(), running.gl_window.window()); + .save(running.app.as_mut(), running.gl_window.window.as_ref()); running.app.on_exit(Some(&running.gl)); running.painter.destroy(); } @@ -1260,9 +1260,9 @@ mod wgpu_integration { fn save_and_destroy(&mut self) { if let Some(mut running) = self.running.take() { - if let Some(window) = &self.window { - running.integration.save(running.app.as_mut(), window); - } + running + .integration + .save(running.app.as_mut(), self.window.as_ref()); #[cfg(feature = "glow")] running.app.on_exit(None);