From e29735094f9e2c74d6e7eca2491e4ea90da2a32e Mon Sep 17 00:00:00 2001 From: kerty Date: Thu, 31 Oct 2024 16:58:37 +0300 Subject: [PATCH 1/2] Fix memory leak and stopped animation --- daemon/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/daemon/src/main.rs b/daemon/src/main.rs index dd0e434..d5b3c5f 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -375,7 +375,6 @@ impl wayland::interfaces::wl_output::EvHandler for Daemon { wallpaper .borrow_mut() .commit_surface_changes(self.use_cache); - self.stop_animations(&[wallpaper.clone()]); break; } } @@ -480,8 +479,14 @@ impl wayland::interfaces::zwlr_layer_surface_v1::EvHandler for Daemon { } fn closed(&mut self, sender_id: ObjectId) { - self.wallpapers - .retain(|w| !w.borrow().has_layer_surface(sender_id)); + if let Some(i) = self + .wallpapers + .iter() + .position(|w| w.borrow().has_layer_surface(sender_id)) + { + let w = self.wallpapers.remove(i); + self.stop_animations(&[w]); + } } } From 87869b20c438d0b903f267940b71deaa37824e4b Mon Sep 17 00:00:00 2001 From: kerty Date: Fri, 1 Nov 2024 20:49:35 +0300 Subject: [PATCH 2/2] Fix crush when changing monitor configuration --- daemon/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/daemon/src/main.rs b/daemon/src/main.rs index d5b3c5f..7d9cfb3 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -372,9 +372,12 @@ impl wayland::interfaces::wl_output::EvHandler for Daemon { fn done(&mut self, sender_id: ObjectId) { for wallpaper in self.wallpapers.iter() { if wallpaper.borrow().has_output(sender_id) { - wallpaper + if wallpaper .borrow_mut() - .commit_surface_changes(self.use_cache); + .commit_surface_changes(self.use_cache) + { + self.stop_animations(&[wallpaper.clone()]); + } break; } }