mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
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:
committed by
GitHub
parent
39648f7781
commit
4b50645c93
+6
-2
@@ -55,7 +55,9 @@ pub fn start_app_state_thread(audio_player_state_shared: Arc<Mutex<AudioPlayerSt
|
|||||||
|
|
||||||
if !is_running {
|
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;
|
guard.is_daemon_running = false;
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(500)).await;
|
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 =
|
let full_state: FullState =
|
||||||
serde_json::from_str(&full_state_res.message).unwrap_or_default();
|
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() {
|
guard.state = match guard.new_state.clone() {
|
||||||
Some(new_state) => {
|
Some(new_state) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user