From ee00a24688d3f9c451df998543b85cf60deb3b44 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis <george.kiagiadakis@collabora.com> Date: Thu, 20 Jun 2019 12:50:28 +0300 Subject: [PATCH] core: destroy globals in _dispose() so that the global-removed signal is dispatched signal emission apparently does not work in _finalize() Fixes some critical warnings from remote-endpoint.c because disconnection from the destroyed endpoints did not happen --- lib/wp/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/wp/core.c b/lib/wp/core.c index 326e9b98..82ae5146 100644 --- a/lib/wp/core.c +++ b/lib/wp/core.c @@ -44,15 +44,14 @@ wp_core_init (WpCore * self) } static void -wp_core_finalize (GObject * obj) +wp_core_dispose (GObject * obj) { WpCore *self = WP_CORE (obj); - GPtrArray *global_objects; + g_autoptr (GPtrArray) global_objects; struct global_object *global; gint i; - global_objects = self->global_objects; - self->global_objects = NULL; + global_objects = g_steal_pointer (&self->global_objects); for (i = 0; i < global_objects->len; i++) { global = g_ptr_array_index (global_objects, i); @@ -63,8 +62,12 @@ wp_core_finalize (GObject * obj) global->destroy (global->object); } - g_ptr_array_unref (global_objects); + G_OBJECT_CLASS (wp_core_parent_class)->dispose (obj); +} +static void +wp_core_finalize (GObject * obj) +{ g_debug ("WpCore destroyed"); G_OBJECT_CLASS (wp_core_parent_class)->finalize (obj); @@ -74,6 +77,8 @@ static void wp_core_class_init (WpCoreClass * klass) { GObjectClass *object_class = (GObjectClass *) klass; + + object_class->dispose = wp_core_dispose; object_class->finalize = wp_core_finalize; signals[SIGNAL_GLOBAL_ADDED] = g_signal_new ("global-added", -- GitLab