diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-30 10:50:02 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-30 10:50:02 +0400 |
| commit | a90221d924ff4a02d9f76c58471092ba0090b6d1 (patch) | |
| tree | 3f4a3968450c71f02f9c5458bc3fcf766d68f690 | |
| parent | ab228165212a7fc1911044bcf9a1f1d84cdaf5a3 (diff) | |
| download | niri-a90221d924ff4a02d9f76c58471092ba0090b6d1.tar.gz niri-a90221d924ff4a02d9f76c58471092ba0090b6d1.tar.bz2 niri-a90221d924ff4a02d9f76c58471092ba0090b6d1.zip | |
Fix crash when stopping screencast session twice
| -rw-r--r-- | src/dbus/mutter_screen_cast.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dbus/mutter_screen_cast.rs b/src/dbus/mutter_screen_cast.rs index 853fe4ae..9c7ffb28 100644 --- a/src/dbus/mutter_screen_cast.rs +++ b/src/dbus/mutter_screen_cast.rs @@ -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)), } } } |
