More housekeeping updates. _destroying an element or a pad properly removes if from the parent.

Original commit message from CVS:
More housekeeping updates.
_destroying an element or a pad properly removes if from the parent.
This commit is contained in:
Wim Taymans 2001-05-13 15:29:25 +00:00
parent 6f9ac3667b
commit 3e44dbdb6e
3 changed files with 43 additions and 9 deletions

View file

@ -333,14 +333,15 @@ gst_bin_remove (GstBin *bin,
gst_bin_unset_element_sched (element);
// now remove the element from the list of elements
gst_object_unparent (GST_OBJECT (element));
bin->children = g_list_remove (bin->children, element);
bin->numchildren--;
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "removed child %s", GST_ELEMENT_NAME (element));
gst_object_unparent (GST_OBJECT (element));
/* if we're down to zero children, force state to NULL */
if (bin->numchildren == 0)
if (bin->numchildren == 0 && GST_ELEMENT_SCHED (bin) != NULL)
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
}
@ -505,7 +506,8 @@ gst_bin_real_destroy (GtkObject *object)
children = bin->children;
while (children) {
child = GST_ELEMENT (children->data);
gst_object_unref (GST_OBJECT (child));
//gst_object_unref (GST_OBJECT (child));
gst_object_unparent (GST_OBJECT (child));
children = g_list_next (children);
}

View file

@ -53,6 +53,7 @@ static void gst_element_init (GstElement *element);
static void gst_element_set_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_element_get_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_element_shutdown (GtkObject *object);
static void gst_element_real_destroy (GtkObject *object);
static GstElementStateReturn gst_element_change_state (GstElement *element);
@ -132,6 +133,7 @@ gst_element_class_init (GstElementClass *klass)
gtkobject_class->set_arg = GST_DEBUG_FUNCPTR(gst_element_set_arg);
gtkobject_class->get_arg = GST_DEBUG_FUNCPTR(gst_element_get_arg);
gtkobject_class->shutdown = GST_DEBUG_FUNCPTR(gst_element_shutdown);
gtkobject_class->destroy = GST_DEBUG_FUNCPTR(gst_element_real_destroy);
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR(gst_element_save_thyself);
@ -333,7 +335,7 @@ gst_element_remove_pad (GstElement *element, GstPad *pad)
else
element->numsinkpads--;
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[NEW_PAD], pad);
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[PAD_REMOVED], pad);
gst_object_unparent (GST_OBJECT (pad));
}
@ -877,6 +879,20 @@ GST_ELEMENT_NAME(element),GST_ELEMENT_NAME(GST_ELEMENT_PARENT(element)),GST_ELEM
return TRUE;
}
static void
gst_element_shutdown (GtkObject *object)
{
GstElement *element = GST_ELEMENT (object);
GST_DEBUG_ELEMENT (GST_CAT_REFCOUNTING, element, "shutdown\n");
if (GST_IS_BIN (GST_OBJECT_PARENT (element)))
gst_bin_remove (GST_BIN (GST_OBJECT_PARENT (element)), element);
if (GTK_OBJECT_CLASS (parent_class)->shutdown)
GTK_OBJECT_CLASS (parent_class)->shutdown (object);
}
static void
gst_element_real_destroy (GtkObject *object)
{
@ -884,12 +900,12 @@ gst_element_real_destroy (GtkObject *object)
GList *pads;
GstPad *pad;
GST_DEBUG (GST_CAT_REFCOUNTING, "destroy\n");
GST_DEBUG_ELEMENT (GST_CAT_REFCOUNTING, element, "destroy\n");
pads = element->pads;
while (pads) {
pad = GST_PAD (pads->data);
gst_object_unref (GST_OBJECT (pad));
gst_object_unparent (GST_OBJECT (pad));
pads = g_list_next (pads);
}

View file

@ -97,6 +97,7 @@ static void gst_real_pad_init (GstRealPad *pad);
static void gst_real_pad_set_arg (GtkObject *object,GtkArg *arg,guint id);
static void gst_real_pad_get_arg (GtkObject *object,GtkArg *arg,guint id);
static void gst_real_pad_shutdown (GtkObject *object);
static void gst_real_pad_destroy (GtkObject *object);
static void gst_pad_push_func (GstPad *pad, GstBuffer *buf);
@ -161,9 +162,10 @@ gst_real_pad_class_init (GstRealPadClass *klass)
gtk_object_add_arg_type ("GstRealPad::active", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, REAL_ARG_ACTIVE);
gtkobject_class->destroy = GST_DEBUG_FUNCPTR(gst_real_pad_destroy);
gtkobject_class->set_arg = GST_DEBUG_FUNCPTR(gst_real_pad_set_arg);
gtkobject_class->get_arg = GST_DEBUG_FUNCPTR(gst_real_pad_get_arg);
gtkobject_class->shutdown = GST_DEBUG_FUNCPTR(gst_real_pad_shutdown);
gtkobject_class->destroy = GST_DEBUG_FUNCPTR(gst_real_pad_destroy);
gtkobject_class->set_arg = GST_DEBUG_FUNCPTR(gst_real_pad_set_arg);
gtkobject_class->get_arg = GST_DEBUG_FUNCPTR(gst_real_pad_get_arg);
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR(gst_pad_save_thyself);
gstobject_class->path_string_separator = ".";
@ -1009,6 +1011,20 @@ gst_pad_get_bufferpool (GstPad *pad)
}
}
static void
gst_real_pad_shutdown (GtkObject *object)
{
GstPad *pad = GST_PAD (object);
GST_DEBUG (GST_CAT_REFCOUNTING, "shutdown\n");
if (GST_IS_ELEMENT (GST_OBJECT_PARENT (pad)))
gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad);
if (GTK_OBJECT_CLASS (real_pad_parent_class)->shutdown)
GTK_OBJECT_CLASS (real_pad_parent_class)->shutdown (object);
}
static void
gst_real_pad_destroy (GtkObject *object)