Skip to content

Commit

Permalink
Avoid some crashes in the process scanner thread
Browse files Browse the repository at this point in the history
get_window_process() can fail for many reasons, one of them being lack
of permission to inject into some processes.

Before this change, the process scanner thread could crash by simply
launching the Task Manager (taskmgr.exe), before we injected into
Spotify.

I also added a check for event.window_handle(), just to be safe.
  • Loading branch information
guihkx committed Apr 11, 2024
1 parent debd4de commit 0e7bd22
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions burnt-sushi/src/spotify_process_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ impl SpotifyProcessScanner {
while let Some(event) = event_rx.recv().await {
// scoped to make future Send
let state = {
let window = event.window_handle().unwrap();
let process = get_window_process(window)?;
let Some(window) = event.window_handle() else {
continue;
};
let Ok(process) = get_window_process(window) else {
continue;
};
if !is_spotify_process(process.borrowed()) || !is_main_spotify_window(window) {
continue;
}
Expand Down

0 comments on commit 0e7bd22

Please sign in to comment.