From e603ed42154a8bdf71792db9e4ee63eda07a401b Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Tue, 18 Jun 2019 10:33:09 +0300
Subject: [PATCH] lib: add some debug statements to debug the destruction
 sequence

---
 lib/wp/core.c     | 2 ++
 lib/wp/endpoint.c | 3 +++
 lib/wp/policy.c   | 2 ++
 lib/wp/proxy.c    | 3 +++
 lib/wp/remote.c   | 2 ++
 5 files changed, 12 insertions(+)

diff --git a/lib/wp/core.c b/lib/wp/core.c
index 2f1d27e0..4a16bf47 100644
--- a/lib/wp/core.c
+++ b/lib/wp/core.c
@@ -65,6 +65,8 @@ wp_core_finalize (GObject * obj)
 
   g_ptr_array_unref (global_objects);
 
+  g_debug ("WpCore destroyed");
+
   G_OBJECT_CLASS (wp_core_parent_class)->finalize (obj);
 }
 
diff --git a/lib/wp/endpoint.c b/lib/wp/endpoint.c
index 21d32e26..f971aef3 100644
--- a/lib/wp/endpoint.c
+++ b/lib/wp/endpoint.c
@@ -151,6 +151,9 @@ wp_endpoint_finalize (GObject * object)
   WpEndpointPrivate *priv =
       wp_endpoint_get_instance_private (WP_ENDPOINT (object));
 
+  g_debug ("%s:%p destroyed: %s", G_OBJECT_TYPE_NAME (object), object,
+      priv->name);
+
   g_ptr_array_unref (priv->streams);
   g_ptr_array_unref (priv->controls);
   g_ptr_array_unref (priv->links);
diff --git a/lib/wp/policy.c b/lib/wp/policy.c
index ccabc221..45b8161c 100644
--- a/lib/wp/policy.c
+++ b/lib/wp/policy.c
@@ -35,6 +35,8 @@ wp_policy_manager_finalize (GObject *object)
 {
   WpPolicyManager *self = WP_POLICY_MANAGER (object);
 
+  g_debug ("WpPolicyManager destroyed");
+
   g_list_free_full (self->policies, g_object_unref);
 
   G_OBJECT_CLASS (wp_policy_manager_parent_class)->finalize (object);
diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c
index 7815f701..8926f6d1 100644
--- a/lib/wp/proxy.c
+++ b/lib/wp/proxy.c
@@ -80,6 +80,9 @@ wp_proxy_finalize (GObject * object)
 {
   WpProxyPrivate *self = wp_proxy_get_instance_private (WP_PROXY(object));
 
+  g_debug ("%s:%p destroyed (pw proxy %p)", G_OBJECT_TYPE_NAME (object),
+      object, self->proxy);
+
   /* Remove the listener */
   spa_hook_remove (&self->listener);
 
diff --git a/lib/wp/remote.c b/lib/wp/remote.c
index 663d7e7f..bb759a14 100644
--- a/lib/wp/remote.c
+++ b/lib/wp/remote.c
@@ -45,6 +45,8 @@ wp_remote_finalize (GObject *object)
 
   g_weak_ref_clear (&priv->core);
 
+  g_debug ("%s destroyed", G_OBJECT_TYPE_NAME (object));
+
   G_OBJECT_CLASS (wp_remote_parent_class)->finalize (object);
 }
 
-- 
GitLab