From 21a48ac735f9f2f5e4384cb84e756897f07da61c Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 1 Nov 2026 12:54:00 +0100 Subject: [PATCH] fix(ui): finish font discovery when its worker panics Contain discovery panics and publish the empty result so the font menu leaves its pending state. A synthetic panic regression fails when containment is removed. Co-Authored-By: Codex GPT-6.1 --- crates/ui-egui/src/workflows/files.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/workflows/files.rs b/crates/ui-egui/src/workflows/files.rs index a9313a4714..17870e5b1a 100644 --- a/crates/ui-egui/src/workflows/files.rs +++ b/crates/ui-egui/src/workflows/files.rs @@ -28,6 +28,13 @@ pub enum FilePurpose { RedactWords, } +#[cfg(not(target_arch = "wasm32"))] +fn discover_fonts_safely( + discover: impl FnOnce() -> Vec + std::panic::UnwindSafe, +) -> Vec { + std::panic::catch_unwind(discover).unwrap_or_default() +} + /// Discover installed document fonts off the GUI thread, only when the picker is opened. #[cfg(not(target_arch = "wasm32"))] pub(crate) fn installed_font_files(ctx: &egui::Context) -> Option> { @@ -41,7 +48,7 @@ pub(crate) fn installed_font_files(ctx: &egui::Context) -> Option