Skip to content

Commit

Permalink
Prevent crashing when non-active player is modified
Browse files Browse the repository at this point in the history
  • Loading branch information
hafeoz committed Feb 3, 2025
1 parent 5e71a39 commit aa5ff98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "waylrc"
version = "2.1.0"
version = "2.1.1"
edition = "2021"
authors = ["hafeoz <[email protected]>"]
description = "A Waybar module to display currently playing song lyrics"
Expand Down
9 changes: 7 additions & 2 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ struct CurrentPlayerState {
next_lrc_timetag: TimeTag,
}

pub async fn event_loop(conn: Connection, refresh_interval: Duration, filter_keys: HashSet<String>) -> Result<()> {
pub async fn event_loop(
conn: Connection,
refresh_interval: Duration,
filter_keys: HashSet<String>,
) -> Result<()> {
let mut dbus_stream = player_buses(&conn).await?;

let (player_update_sender, mut player_update_receiver) = mpsc::channel(1);
Expand Down Expand Up @@ -135,7 +139,8 @@ pub async fn event_loop(conn: Connection, refresh_interval: Duration, filter_key
_ => None
};

if let Some(player) = current_player.take().filter(|p| p.bus == bus_name) {
if current_player.as_ref().map(|p| &p.bus) == Some(&bus_name) {
let player = current_player.take().unwrap();
// This player is the current player
tracing::info!(%bus_name, "Currently active player modified");
if scanner::is_player_active(info) {
Expand Down

0 comments on commit aa5ff98

Please sign in to comment.