From 94b1390d0eb3dd26b2972d123ddfd845e9222d56 Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Tue, 17 Sep 2019 19:53:20 +0300
Subject: [PATCH] proxy: destroy the pw_proxy in dispose()

Because the proxy_event_destroy() handler now takes a ref to the
WpProxy, which is an error to do in finalize()
---
 lib/wp/proxy.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c
index 876a721d..f0969d2c 100644
--- a/lib/wp/proxy.c
+++ b/lib/wp/proxy.c
@@ -212,6 +212,18 @@ wp_proxy_constructed (GObject * object)
     wp_proxy_got_pw_proxy (self);
 }
 
+static void
+wp_proxy_dispose (GObject * object)
+{
+  WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object));
+
+  /* this will trigger proxy_event_destroy() if the pw_proxy exists */
+  if (priv->pw_proxy)
+    pw_proxy_destroy (priv->pw_proxy);
+
+  G_OBJECT_CLASS (wp_proxy_parent_class)->dispose (object);
+}
+
 static void
 wp_proxy_finalize (GObject * object)
 {
@@ -220,7 +232,6 @@ wp_proxy_finalize (GObject * object)
   g_debug ("%s:%p destroyed (global %u; pw_proxy %p)",
       G_OBJECT_TYPE_NAME (object), object, priv->global_id, priv->pw_proxy);
 
-  g_clear_pointer (&priv->pw_proxy, pw_proxy_destroy);
   g_clear_object (&priv->task);
   g_clear_pointer (&priv->global_props, wp_properties_unref);
   g_weak_ref_clear (&priv->core);
@@ -346,6 +357,7 @@ wp_proxy_class_init (WpProxyClass * klass)
   GObjectClass *object_class = (GObjectClass *) klass;
 
   object_class->constructed = wp_proxy_constructed;
+  object_class->dispose = wp_proxy_dispose;
   object_class->finalize = wp_proxy_finalize;
   object_class->get_property = wp_proxy_get_property;
   object_class->set_property = wp_proxy_set_property;
-- 
GitLab