From 6bdc6fb6978f80e28b9934b0bcbbda3f609241b8 Mon Sep 17 00:00:00 2001 From: Ashok Sidipotu Date: Wed, 13 Jul 2022 06:32:11 +0530 Subject: [PATCH] event-dispatcher: Donot cancel the object-removed event The event is not reaching the object-removal hooks due to this. --- lib/wp/event-dispatcher.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/wp/event-dispatcher.c b/lib/wp/event-dispatcher.c index 54faa2dd..7dd38753 100644 --- a/lib/wp/event-dispatcher.c +++ b/lib/wp/event-dispatcher.c @@ -44,6 +44,20 @@ form_event_name (const gchar *type, const gchar *subject_type) (subject_type ? subject_type : "")); } +static void +on_proxy_destroyed (GObject* self, WpEvent* e) +{ + if (e->subject == self) + { + const gchar* type = wp_properties_get (e->properties, "event.type"); + /* object removal needs to be processed by hooks */ + if (g_str_equal (type, "object-removed")) + wp_properties_set (e->properties, "pw-proxy-destroyed", "true"); + else + g_cancellable_cancel (e->cancellable); + } +} + /*! * \brief Creates a new event * \ingroup wpevent @@ -96,9 +110,8 @@ wp_event_new (const gchar * type, gint priority, WpProperties * properties, /* watch for subject pw-proxy-destroyed and cancel event */ if (g_type_is_a (G_OBJECT_TYPE (self->subject), WP_TYPE_PROXY)) { - g_signal_connect_object (self->subject, "pw-proxy-destroyed", - (GCallback) g_cancellable_cancel, self->cancellable, - G_CONNECT_SWAPPED); + g_signal_connect (self->subject, "pw-proxy-destroyed", + (GCallback) on_proxy_destroyed, self); } }