Fix crash when stopping screencast session twice

This commit is contained in:
Ivan Molodetskikh
2024-03-30 10:50:02 +04:00
parent ab22816521
commit a90221d924
+7
View File
@@ -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)]
@@ -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 {
@@ -255,6 +261,7 @@ impl Session {
ipc_outputs,
streams: Arc::new(Mutex::new(vec![])),
to_niri,
stopped: Arc::new(AtomicBool::new(false)),
}
}
}