diff --git a/gst/gstelement.c b/gst/gstelement.c index effd6a8c90..c4501f11bc 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -328,8 +328,15 @@ gst_element_remove_pad (GstElement *element, GstPad *pad) g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (GST_PAD_PARENT (pad) == element); - - /* add it to the list */ + /* check to see if the pad is still connected */ + /* FIXME: what if someone calls _remove_pad instead of + _remove_ghost_pad? */ + if (GST_IS_REAL_PAD (pad)) + { + g_return_if_fail (GST_RPAD_PEER (pad) == NULL); + } + + /* remove it from the list */ element->pads = g_list_remove (element->pads, pad); element->numpads--; if (gst_pad_get_direction (pad) == GST_PAD_SRC) @@ -1188,7 +1195,12 @@ gst_element_dispose (GObject *object) orig = pads = g_list_copy (element->pads); while (pads) { pad = GST_PAD (pads->data); - gst_object_destroy (GST_OBJECT (pad)); + if (GST_PAD_PEER (pad)) + { + GST_DEBUG (GST_CAT_REFCOUNTING, "disconnecting pad '%s'\n",GST_OBJECT_NAME(GST_OBJECT (GST_PAD (GST_PAD_PEER (pad))))); + gst_pad_disconnect (pad, GST_PAD (GST_PAD_PEER (pad))); + } + gst_element_remove_pad (element, pad); pads = g_list_next (pads); } g_list_free (orig); diff --git a/gst/gstpad.c b/gst/gstpad.c index f39163e47d..fc77e61be6 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1427,6 +1427,10 @@ gst_real_pad_dispose (GObject *object) { GstPad *pad = GST_PAD (object); + /* No connected pad can ever be disposed. + * It has to have a parent to be connected and a parent would hold a reference */ + g_assert (GST_PAD_PEER (pad) == NULL); + GST_DEBUG (GST_CAT_REFCOUNTING, "dispose %s:%s\n", GST_DEBUG_PAD_NAME(pad)); if (GST_PAD_PADTEMPLATE (pad)){ @@ -1435,11 +1439,6 @@ gst_real_pad_dispose (GObject *object) GST_PAD_PADTEMPLATE (pad) = NULL; } - if (GST_PAD_PEER (pad)){ - GST_DEBUG (GST_CAT_REFCOUNTING, "disconnecting pad '%s'\n", GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad))))); - gst_pad_disconnect (pad, GST_PAD (GST_PAD_PEER (pad))); - } - /* we destroy the ghostpads, because they are nothing without the real pad */ if (GST_REAL_PAD (pad)->ghostpads) { GList *orig, *ghostpads;