From cf684051dda593a71688980fe83263a48941be44 Mon Sep 17 00:00:00 2001 From: Tulio Beloqui Date: Fri, 29 May 2020 11:29:56 -0300 Subject: [PATCH] gstdevicemonitor: added cleanup of signal handlers and hidden providers list Part-of: --- subprojects/gstreamer/gst/gstdevicemonitor.c | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/subprojects/gstreamer/gst/gstdevicemonitor.c b/subprojects/gstreamer/gst/gstdevicemonitor.c index e54dfac891..4beea72dd5 100644 --- a/subprojects/gstreamer/gst/gstdevicemonitor.c +++ b/subprojects/gstreamer/gst/gstdevicemonitor.c @@ -132,6 +132,14 @@ static void gst_device_monitor_dispose (GObject * object); static guint gst_device_monitor_add_filter_unlocked (GstDeviceMonitor * monitor, const gchar * classes, GstCaps * caps); +static void +provider_hidden (GstDeviceProvider * provider, const gchar * hidden, + GstDeviceMonitor * monitor); + +static void +provider_unhidden (GstDeviceProvider * provider, const gchar * hidden, + GstDeviceMonitor * monitor); + struct DeviceFilter { guint id; @@ -319,7 +327,7 @@ gst_device_monitor_init (GstDeviceMonitor * self) static void -gst_device_monitor_remove (GstDeviceMonitor * self, guint i) +gst_device_monitor_remove_provider (GstDeviceMonitor * self, guint i) { GstDeviceProvider *provider = g_ptr_array_index (self->priv->providers, i); GstBus *bus; @@ -330,6 +338,9 @@ gst_device_monitor_remove (GstDeviceMonitor * self, guint i) g_signal_handlers_disconnect_by_func (bus, bus_sync_message, self); gst_object_unref (bus); + g_signal_handlers_disconnect_by_func (provider, provider_hidden, self); + g_signal_handlers_disconnect_by_func (provider, provider_unhidden, self); + gst_object_unref (provider); } @@ -342,7 +353,7 @@ gst_device_monitor_dispose (GObject * object) if (self->priv->providers) { while (self->priv->providers->len) - gst_device_monitor_remove (self, self->priv->providers->len - 1); + gst_device_monitor_remove_provider (self, self->priv->providers->len - 1); g_ptr_array_unref (self->priv->providers); self->priv->providers = NULL; } @@ -352,6 +363,11 @@ gst_device_monitor_dispose (GObject * object) self->priv->filters = NULL; } + if (self->priv->hidden) { + g_list_free_full (self->priv->hidden, g_free); + self->priv->hidden = NULL; + } + gst_object_replace ((GstObject **) & self->priv->bus, NULL); G_OBJECT_CLASS (gst_device_monitor_parent_class)->dispose (object); @@ -774,7 +790,7 @@ gst_device_monitor_remove_filter (GstDeviceMonitor * monitor, guint filter_id) } if (!valid) { - gst_device_monitor_remove (monitor, i); + gst_device_monitor_remove_provider (monitor, i); i--; } }