From d9696c1c448f3c7f1d2d2c23823c3ec79e47473d Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Fri, 13 Dec 2024 22:59:50 +0200 Subject: [PATCH] fix(visualizer): dont destroy on unmap --- src/Widgets/AudioPlayer/Player.vala | 10 ++++++---- src/Widgets/AudioPlayer/Stream.vala | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Widgets/AudioPlayer/Player.vala b/src/Widgets/AudioPlayer/Player.vala index 3d494cd1f..549dbae71 100644 --- a/src/Widgets/AudioPlayer/Player.vala +++ b/src/Widgets/AudioPlayer/Player.vala @@ -58,6 +58,7 @@ public class Tuba.Widgets.Audio.Player : Adw.Bin { player.ended.connect (on_ended); this.child = overlay; + this.destroy.connect (on_destroy); } private void on_ended () { @@ -130,10 +131,11 @@ public class Tuba.Widgets.Audio.Player : Adw.Bin { on_reveal_media_buttons (); } - public override void unmap () { - if (revealer_timeout > 0) GLib.Source.remove (revealer_timeout); - - base.unmap (); + private void on_destroy () { + if (revealer_timeout > 0) { + GLib.Source.remove (revealer_timeout); + revealer_timeout = 0; + } player.destroy (); } diff --git a/src/Widgets/AudioPlayer/Stream.vala b/src/Widgets/AudioPlayer/Stream.vala index ce6783c8b..f236f37b4 100644 --- a/src/Widgets/AudioPlayer/Stream.vala +++ b/src/Widgets/AudioPlayer/Stream.vala @@ -144,11 +144,20 @@ public class Tuba.Widgets.Audio.Stream : GLib.Object { // Without disconnecting everything // it leaks. public void destroy () { - if (timeout_id > 0) GLib.Source.remove (timeout_id); - bus.remove_watch (); - bus = null; - this.state = Gst.State.NULL; - pipeline = null; + if (timeout_id > 0) { + GLib.Source.remove (timeout_id); + timeout_id = 0; + } + + if (bus != null) { + bus.remove_watch (); + bus = null; + } + + if (pipeline != null) { + this.state = Gst.State.NULL; + pipeline = null; + } } ~Stream () {