From a5e44ffffaa6d7a8d7af8dcb77e37990996253a5 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 4 Dec 2010 18:53:55 -0800 Subject: [PATCH] element: Call ->release_pad() to clean up pad Fixes #636011 and #402562. --- gst/gstelement.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index 9323b94..a67458a 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -335,6 +335,8 @@ gst_element_release_request_pad (GstElement * element, GstPad * pad) g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (GST_PAD_TEMPLATE_PRESENCE (GST_PAD_PAD_TEMPLATE (pad)) + == GST_PAD_REQUEST); oclass = GST_ELEMENT_GET_CLASS (element); @@ -2958,6 +2960,9 @@ gst_element_dispose (GObject * object) GstElement *element = GST_ELEMENT_CAST (object); GstClock **clock_p; GstBus **bus_p; + GstElementClass *oclass; + + oclass = GST_ELEMENT_GET_CLASS (element); GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose"); @@ -2968,8 +2973,15 @@ gst_element_dispose (GObject * object) "removing %d pads", g_list_length (element->pads)); /* first we break all our links with the outside */ while (element->pads && element->pads->data) { + GstPad *pad = GST_PAD_CAST (element->pads->data); + /* don't call _remove_pad with NULL */ - gst_element_remove_pad (element, GST_PAD_CAST (element->pads->data)); + if (oclass->release_pad && GST_PAD_PAD_TEMPLATE (pad) && + GST_PAD_TEMPLATE_PRESENCE (GST_PAD_PAD_TEMPLATE (pad)) + == GST_PAD_REQUEST) + (oclass->release_pad) (element, GST_PAD_CAST (element->pads->data)); + else + gst_element_remove_pad (element, GST_PAD_CAST (element->pads->data)); } if (G_UNLIKELY (element->pads != NULL)) { g_critical ("could not remove pads from element %s", -- 2.7.4