A free, open source, and extensible speech-to-text application that works completely offline.
fix: prevent abort on quit by handling poisoned mutexes in Drop impls (#1354)
Marcel Diasa6df742880ad
diff --git a/src-tauri/src/managers/transcription.rs b/src-tauri/src/managers/transcription.rsindex 6ba5c344..61f95fe3 100644--- a/src-tauri/src/managers/transcription.rs+++ b/src-tauri/src/managers/transcription.rs@@ -179,7 +179,12 @@ pub struct LoadingGuard {impl Drop for LoadingGuard {fn drop(&mut self) {- let mut is_loading = self.is_loading.lock().unwrap();+ // Recover from a poisoned mutex instead of panicking —+ // a panic inside Drop calls abort().+ let mut is_loading = match self.is_loading.lock() {+ Ok(g) => g,+ Err(e) => e.into_inner(),+ };*is_loading = false;self.loading_condvar.notify_all();}@@ -1939,8 +1944,14 @@ impl Drop for TranscriptionManager {// Signal the watcher thread to shutdownself.shutdown_signal.store(true, Ordering::Relaxed);- // Wait for the thread to finish gracefully- if let Some(handle) = self.watcher_handle.lock().unwrap().take() {+ // Wait for the thread to finish gracefully.+ // Use match instead of unwrap to avoid panicking if the mutex is+ // poisoned — a panic inside Drop calls abort().+ let mut guard = match self.watcher_handle.lock() {+ Ok(g) => g,+ Err(e) => e.into_inner(),+ };+ if let Some(handle) = guard.take() {if let Err(e) = handle.join() {warn!("Failed to join idle watcher thread: {:?}", e);} else {