refactor(gui): replace unsafe unwrap on gui thread lock (#23)

Replaces `audio_player_state_shared.lock().unwrap()` with `.unwrap_or_else(|e| e.into_inner())` in `src/utils/gui.rs` to allow safe recovery from poisoned locks and avoid application panics.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Tarasov Aleksandr
2026-03-08 00:25:42 +03:00
committed by GitHub
parent 39648f7781
commit 4b50645c93
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -55,7 +55,9 @@ pub fn start_app_state_thread(audio_player_state_shared: Arc<Mutex<AudioPlayerSt
if !is_running {
{
let mut guard = audio_player_state_shared.lock().unwrap();
let mut guard = audio_player_state_shared
.lock()
.unwrap_or_else(|e| e.into_inner());
guard.is_daemon_running = false;
}
sleep(Duration::from_millis(500)).await;
@@ -69,7 +71,9 @@ pub fn start_app_state_thread(audio_player_state_shared: Arc<Mutex<AudioPlayerSt
let full_state: FullState =
serde_json::from_str(&full_state_res.message).unwrap_or_default();
let mut guard = audio_player_state_shared.lock().unwrap();
let mut guard = audio_player_state_shared
.lock()
.unwrap_or_else(|e| e.into_inner());
guard.state = match guard.new_state.clone() {
Some(new_state) => {