From c2a944965ad869b5620128be7a8bf23975bb7873 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 22 Jan 2016 19:38:53 +0100 Subject: [PATCH] validate: Guarantee that we never create 2 monitors for the same object Differential Revision: https://phabricator.freedesktop.org/D702 --- validate/gst/validate/gst-validate-bin-monitor.c | 2 -- validate/gst/validate/gst-validate-element-monitor.c | 2 -- validate/gst/validate/gst-validate-monitor-factory.c | 11 +++++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/validate/gst/validate/gst-validate-bin-monitor.c b/validate/gst/validate/gst-validate-bin-monitor.c index fdb5125e..241c606 100644 --- a/validate/gst/validate/gst-validate-bin-monitor.c +++ b/validate/gst/validate/gst-validate-bin-monitor.c @@ -207,8 +207,6 @@ gst_validate_bin_monitor_setup (GstValidateMonitor * monitor) return FALSE; } - g_object_set_data ((GObject *) bin, "validate-monitor", bin_monitor); - bin_monitor->element_added_id = g_signal_connect (bin, "element-added", G_CALLBACK (_validate_bin_element_added), monitor); diff --git a/validate/gst/validate/gst-validate-element-monitor.c b/validate/gst/validate/gst-validate-element-monitor.c index 7d9f945..b518c21 100644 --- a/validate/gst/validate/gst-validate-element-monitor.c +++ b/validate/gst/validate/gst-validate-element-monitor.c @@ -248,8 +248,6 @@ gst_validate_element_monitor_do_setup (GstValidateMonitor * monitor) return FALSE; } - g_object_set_data ((GObject *) element, "validate-monitor", elem_monitor); - gst_validate_element_monitor_inspect (elem_monitor); elem_monitor->pad_added_id = g_signal_connect (element, "pad-added", diff --git a/validate/gst/validate/gst-validate-monitor-factory.c b/validate/gst/validate/gst-validate-monitor-factory.c index cc3cb65..56ffc92 100644 --- a/validate/gst/validate/gst-validate-monitor-factory.c +++ b/validate/gst/validate/gst-validate-monitor-factory.c @@ -57,6 +57,14 @@ gst_validate_monitor_factory_create (GstObject * target, GstValidateMonitor *monitor = NULL; g_return_val_if_fail (target != NULL, NULL); + monitor = g_object_get_data ((GObject *) target, "validate-monitor"); + if (monitor) { + GST_INFO_OBJECT (target, "Is already monitored by %" GST_PTR_FORMAT, + monitor); + + return g_object_ref (monitor); + } + if (GST_IS_PAD (target)) { monitor = GST_VALIDATE_MONITOR_CAST (gst_validate_pad_monitor_new (GST_PAD_CAST @@ -73,8 +81,11 @@ gst_validate_monitor_factory_create (GstObject * target, monitor = GST_VALIDATE_MONITOR_CAST (gst_validate_element_monitor_new (GST_ELEMENT_CAST (target), runner, parent)); + } else { + g_assert_not_reached (); } + g_object_set_data ((GObject *) target, "validate-monitor", monitor); gst_validate_override_registry_attach_overrides (monitor); return monitor; } -- 2.7.4