From 64dcceea22837eb4b270d6b4905c245497b16c59 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 26 Oct 2024 00:00:20 +0200 Subject: [PATCH] debug destructors --- src/application.vala | 4 ++++ src/mpris.vala | 8 ++++++++ src/playbin.vala | 9 ++++++++- src/subsonic.vala | 4 ++++ src/ui/play_queue.vala | 8 ++++++-- src/ui/playbar.vala | 6 +++++- src/ui/setup.vala | 4 ++++ src/ui/window.vala | 4 ++++ src/vapi/mpv.vapi | 6 +++++- 9 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/application.vala b/src/application.vala index 32fe6b3..74cf982 100644 --- a/src/application.vala +++ b/src/application.vala @@ -41,4 +41,8 @@ public class Audrey.Application : Adw.Application { private void on_preferences_action () { message ("app.preferences action activated"); } + + ~Application () { + debug ("destroying application"); + } } diff --git a/src/mpris.vala b/src/mpris.vala index 96b16cf..e99e2ad 100644 --- a/src/mpris.vala +++ b/src/mpris.vala @@ -20,6 +20,10 @@ class Mpris : Object { public string desktop_entry { owned get { return "eu.callcc.audrey"; } } public string[] supported_uri_schemes { owned get { return {}; } } public string[] supported_mime_types { owned get { return {}; } } + + ~Mpris () { + debug ("destroying mpris"); + } } [DBus (name = "org.mpris.MediaPlayer2.Player")] @@ -62,4 +66,8 @@ class MprisPlayer : Object { public bool can_seek { get; default = false; } [CCode (notify = false)] public bool can_control { get { return false; } } + + ~MprisPlayer () { + debug ("destroying mpris player"); + } } diff --git a/src/playbin.vala b/src/playbin.vala index a28ab73..6db65a1 100644 --- a/src/playbin.vala +++ b/src/playbin.vala @@ -52,7 +52,7 @@ public class Playbin : GLib.Object { public double position { get; private set; default = 0.0; } public double duration { get; private set; default = 0.0; } - public Subsonic.Client api { get; set; default = null; } + public weak Subsonic.Client api { get; set; default = null; } public ListStore _play_queue; public ListModel play_queue { get { return this._play_queue; } } @@ -93,6 +93,9 @@ public class Playbin : GLib.Object { IOChannel wakeup_read = new IOChannel.unix_new (wakeup_fds[0]); IOChannel wakeup_write = new IOChannel.unix_new (wakeup_fds[1]); + wakeup_read.set_close_on_unref (true); + wakeup_write.set_close_on_unref (true); + try { wakeup_read.set_encoding (null); wakeup_write.set_encoding (null); @@ -385,4 +388,8 @@ public class Playbin : GLib.Object { else if (this.play_queue_position >= to && this.play_queue_position < from) this.play_queue_position += 1; } } + + ~Playbin () { + debug ("destroying playbin"); + } } diff --git a/src/subsonic.vala b/src/subsonic.vala index 14fcb7a..427b4c9 100644 --- a/src/subsonic.vala +++ b/src/subsonic.vala @@ -248,4 +248,8 @@ public class Subsonic.Client : Object { assert (msg.get_status () == Soup.Status.OK); return yield new Gdk.Pixbuf.from_stream_async (stream, cancellable); } + + ~Client () { + debug ("destroying subsonic client"); + } } diff --git a/src/ui/play_queue.vala b/src/ui/play_queue.vala index abadf21..c08b50f 100644 --- a/src/ui/play_queue.vala +++ b/src/ui/play_queue.vala @@ -23,7 +23,7 @@ class Ui.PlayQueueSong : Gtk.Box { public string play_icon_name { get; set; default = ""; } - private Playbin playbin; + private weak Playbin playbin; public PlayQueueSong (Playbin playbin) { this.playbin = playbin; @@ -110,7 +110,7 @@ class Ui.PlayQueueSong : Gtk.Box { [GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue.ui")] public class Ui.PlayQueue : Gtk.Box { - private Playbin _playbin; + private weak Playbin _playbin; public Playbin playbin { get { return _playbin; } set { @@ -165,4 +165,8 @@ public class Ui.PlayQueue : Gtk.Box { [GtkCallback] private string visible_child_name (uint n_items) { return n_items > 0 ? "not-empty" : "empty"; } + + ~PlayQueue () { + debug ("destroying play queue widget"); + } } diff --git a/src/ui/playbar.vala b/src/ui/playbar.vala index 4c9e876..a555a12 100644 --- a/src/ui/playbar.vala +++ b/src/ui/playbar.vala @@ -2,7 +2,7 @@ class Ui.Playbar : Gtk.Box { public Subsonic.Song? song { get; set; } public Gdk.Paintable? playing_cover_art { get; set; } - public Playbin playbin { get; set; } + public weak Playbin playbin { get; set; } public bool show_cover_art { get; set; default = true; } public int volume { @@ -82,4 +82,8 @@ class Ui.Playbar : Gtk.Box { [GtkCallback] private string song_album (Subsonic.Song? song) { return song == null ? "" : song.album; } + + ~Playbar () { + debug ("destroying playbar widget"); + } } diff --git a/src/ui/setup.vala b/src/ui/setup.vala index f73dd14..29abebf 100644 --- a/src/ui/setup.vala +++ b/src/ui/setup.vala @@ -128,4 +128,8 @@ public class Ui.Setup : Adw.PreferencesDialog { this.authn_can_edit = true; }, "server-url", this.server_url, "username", this.username); } + + ~Setup () { + debug ("destroying setup dialog"); + } } diff --git a/src/ui/window.vala b/src/ui/window.vala index cc66861..91bb496 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -115,4 +115,8 @@ class Ui.Window : Adw.ApplicationWindow { [GtkCallback] private bool show_playbar_cover_art (string? stack_child) { return stack_child != "play-queue"; } + + ~Window () { + debug ("destroying main window"); + } } diff --git a/src/vapi/mpv.vapi b/src/vapi/mpv.vapi index 278eb5e..635e647 100644 --- a/src/vapi/mpv.vapi +++ b/src/vapi/mpv.vapi @@ -31,7 +31,7 @@ namespace Mpv { public delegate void WakeupCallback (); - [CCode (cname = "mpv_handle", free_function = "mpv_destroy")] + [CCode (cname = "mpv_handle", free_function = "mpv_terminate_destroy")] [Compact] public class Handle { [CCode (cname = "mpv_create")] @@ -70,6 +70,10 @@ namespace Mpv { [CCode (cname = "mpv_observe_property")] public Error observe_property (uint64 reply_userdata, string name, Format format); + + ~Handle () { + GLib.debug ("destroying mpv handle"); + } } [CCode (cname = "mpv_format", cprefix = "MPV_FORMAT_", has_type_id = false)]