Skip to content

Commit

Permalink
Fix crash when stopping screencast session twice
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Mar 30, 2024
1 parent ab22816 commit a90221d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dbus/mutter_screen_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Session {
to_niri: calloop::channel::Sender<ScreenCastToNiri>,
#[allow(clippy::type_complexity)]
streams: Arc<Mutex<Vec<(Stream, InterfaceRef<Stream>)>>>,
stopped: Arc<AtomicBool>,
}

#[derive(Debug, Default, Deserialize, Type, Clone, Copy)]
Expand Down Expand Up @@ -135,6 +136,11 @@ impl Session {
) {
debug!("stop");

if self.stopped.swap(true, Ordering::SeqCst) {
// Already stopped.
return;
}

Session::closed(&ctxt).await.unwrap();

if let Err(err) = self.to_niri.send(ScreenCastToNiri::StopCast {
Expand Down Expand Up @@ -255,6 +261,7 @@ impl Session {
ipc_outputs,
streams: Arc::new(Mutex::new(vec![])),
to_niri,
stopped: Arc::new(AtomicBool::new(false)),
}
}
}
Expand Down

0 comments on commit a90221d

Please sign in to comment.