From df70f6ad6963ec91e525541a0b624bede8a48edd Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 11 Oct 2026 20:18:11 -0400 Subject: [PATCH] Ignore a corrupt saved window size Co-Authored-By: Claude Opus 5.5 --- apps/soundcraft/src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/soundcraft/src/main.rs b/apps/soundcraft/src/main.rs index 54266c58..1ac7b175 100644 --- a/apps/soundcraft/src/main.rs +++ b/apps/soundcraft/src/main.rs @@ -224,7 +224,7 @@ fn main() -> eframe::Result { let mut options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_title("SoundCraft") - .with_inner_size(prefs.window_size) + .with_inner_size(sane_window_size(prefs.window_size)) .with_maximized(prefs.window_maximized) .with_min_inner_size([960.0, 600.0]) .with_drag_and_drop(true) @@ -275,3 +275,8 @@ fn main() -> eframe::Result { }), ) } + +/// A saved window size, or the default when the prefs file holds nonsense (NaN, negative, tiny). +fn sane_window_size([w, h]: [f32; 2]) -> [f32; 2] { + if w.is_finite() && h.is_finite() && w >= 960.0 && h >= 600.0 { [w.min(16_384.0), h.min(16_384.0)] } else { [1600.0, 1000.0] } +}