slightly different refcount handling. the pad shutdown function doesn't remove the pad from the parent because the pa...

Original commit message from CVS:
slightly different refcount handling. the pad shutdown function doesn't
remove the pad from the parent because the parent is needed in the destroy
function.
This commit is contained in:
Wim Taymans 2001-05-14 21:20:31 +00:00
parent ed06327f06
commit 58085b9304
3 changed files with 33 additions and 23 deletions

View file

@ -904,11 +904,14 @@ gst_element_real_destroy (GtkObject *object)
GST_DEBUG_ELEMENT (GST_CAT_REFCOUNTING, element, "destroy\n");
pads = element->pads;
while (pads) {
pad = GST_PAD (pads->data);
gst_object_unparent (GST_OBJECT (pad));
pads = g_list_next (pads);
if (element->pads) {
pads = g_list_copy (element->pads);
while (pads) {
pad = GST_PAD (pads->data);
gst_object_unparent (GST_OBJECT (pad));
pads = g_list_next (pads);
}
g_list_free (pads);
}
g_list_free (element->pads);

View file

@ -98,7 +98,6 @@ 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);
@ -167,7 +166,6 @@ 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->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);
@ -1014,21 +1012,6 @@ 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)
{
@ -1039,8 +1022,12 @@ gst_real_pad_destroy (GtkObject *object)
if (GST_PAD (pad)->padtemplate)
gst_object_unref (GST_OBJECT (GST_PAD (pad)->padtemplate));
if (GST_PAD_PEER (object))
if (GST_PAD_PEER (object)) {
gst_pad_disconnect (GST_PAD (object), GST_PAD (GST_PAD_PEER (object)));
}
if (GST_IS_ELEMENT (GST_OBJECT_PARENT (pad)))
gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad);
g_list_free (GST_REAL_PAD(pad)->ghostpads);

View file

@ -60,6 +60,8 @@ enum {
static void gst_thread_class_init (GstThreadClass *klass);
static void gst_thread_init (GstThread *thread);
static void gst_thread_real_destroy (GtkObject *gtk_object);
static void gst_thread_set_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_thread_get_arg (GtkObject *object, GtkArg *arg, guint id);
@ -113,6 +115,8 @@ gst_thread_class_init (GstThreadClass *klass)
gtk_object_add_arg_type ("GstThread::create_thread", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_CREATE_THREAD);
gtkobject_class->destroy = gst_thread_real_destroy;
gstobject_class->save_thyself = gst_thread_save_thyself;
gstobject_class->restore_thyself = gst_thread_restore_thyself;
@ -147,6 +151,22 @@ gst_thread_init (GstThread *thread)
// gst_element_set_manager(GST_ELEMENT(thread),GST_ELEMENT(thread));
}
static void
gst_thread_real_destroy (GtkObject *gtk_object)
{
GstThread *thread = GST_THREAD (gtk_object);
GST_DEBUG (GST_CAT_REFCOUNTING,"destroy()\n");
g_mutex_free (thread->lock);
g_cond_free (thread->cond);
gst_object_destroy (GST_ELEMENT_SCHED(thread));
gst_object_unref (GST_ELEMENT_SCHED(thread));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (gtk_object);
}
static void
gst_thread_set_arg (GtkObject *object,