FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
M10.1: system font scan holds a lock for the whole scan — concurrent resolve() could see an empty system font list (found by system_scan_finds_fonts under parallel tests)
Brandon Thomas24ef93702cef
diff --git a/crates/text/src/fonts.rs b/crates/text/src/fonts.rsindex 290a27e1d..809b7c2a6 100644--- a/crates/text/src/fonts.rs+++ b/crates/text/src/fonts.rs@@ -273,17 +273,16 @@ pub fn add_font_data(data: Vec<u8>) -> Vec<FaceId> {/// Scan the system font folders once (native only; a no-op on wasm). Returns the number of faces/// added by this call.pub fn scan_system() -> usize {- {- let mut d = db().write().unwrap_or_else(|e| e.into_inner());- if d.scanned {- return 0;- }- d.scanned = true;- }- if cfg!(target_arch = "wasm32") {+ // Held for the whole scan: a concurrent caller waits for the complete list instead of+ // returning early and resolving against a half-filled database.+ static SCAN: std::sync::Mutex<()> = std::sync::Mutex::new(());+ let _scan = SCAN.lock().unwrap_or_else(|e| e.into_inner());+ if system_scanned() {return 0;}- add_source(&DirectorySource::system())+ let n = if cfg!(target_arch = "wasm32") { 0 } else { add_source(&DirectorySource::system()) };+ db().write().unwrap_or_else(|e| e.into_inner()).scanned = true;+ n}pub fn system_scanned() -> bool {