gst/gstelement.c: Cleanup the error case.

Original commit message from CVS:
* gst/gstelement.c: (gst_element_set_locked_state),
(gst_element_dispose):
Cleanup the error case.
* gst/gstobject.c: (gst_object_dispose):
print a critical when some object was disposed with
a parent, also revive the object since it might
crash the parent.
This commit is contained in:
Wim Taymans 2006-03-22 13:10:16 +00:00
parent 2bafa6ab0d
commit 0e984d3026
3 changed files with 45 additions and 8 deletions

View file

@ -1,3 +1,14 @@
2006-03-22 Wim Taymans <wim@fluendo.com>
* gst/gstelement.c: (gst_element_set_locked_state),
(gst_element_dispose):
Cleanup the error case.
* gst/gstobject.c: (gst_object_dispose):
print a critical when some object was disposed with
a parent, also revive the object since it might
crash the parent.
2006-03-22 Tim-Philipp Müller <tim at centricular dot net> 2006-03-22 Tim-Philipp Müller <tim at centricular dot net>
* tools/gst-launch.1.in: * tools/gst-launch.1.in:

View file

@ -2423,14 +2423,9 @@ gst_element_dispose (GObject * object)
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose"); GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose");
if (GST_STATE (element) != GST_STATE_NULL) { if (GST_STATE (element) != GST_STATE_NULL)
g_critical goto not_null;
("\nTrying to dispose element %s, but it is not in the NULL state.\n"
"You need to explicitly set elements to the NULL state before\n"
"dropping the final reference, to allow them to clean up.\n",
GST_OBJECT_NAME (element));
return;
}
g_return_if_fail (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING); g_return_if_fail (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING);
GST_DEBUG ("removing %d pads", g_list_length (element->pads)); GST_DEBUG ("removing %d pads", g_list_length (element->pads));
@ -2454,6 +2449,19 @@ gst_element_dispose (GObject * object)
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "parent class dispose"); GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "parent class dispose");
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
return;
/* ERRORS */
not_null:
{
g_critical
("\nTrying to dispose element %s, but it is not in the NULL state.\n"
"You need to explicitly set elements to the NULL state before\n"
"dropping the final reference, to allow them to clean up.\n",
GST_OBJECT_NAME (element));
return;
}
} }
static void static void

View file

@ -501,9 +501,13 @@ gst_object_replace (GstObject ** oldobj, GstObject * newobj)
static void static void
gst_object_dispose (GObject * object) gst_object_dispose (GObject * object)
{ {
GstObject *parent;
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose"); GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose");
GST_OBJECT_LOCK (object); GST_OBJECT_LOCK (object);
if ((parent = GST_OBJECT_PARENT (object)))
goto have_parent;
GST_OBJECT_PARENT (object) = NULL; GST_OBJECT_PARENT (object) = NULL;
GST_OBJECT_UNLOCK (object); GST_OBJECT_UNLOCK (object);
@ -511,6 +515,20 @@ gst_object_dispose (GObject * object)
PATCH_REFCOUNT1 (object); PATCH_REFCOUNT1 (object);
parent_class->dispose (object); parent_class->dispose (object);
return;
/* ERRORS */
have_parent:
{
g_critical ("\nTrying to dispose object \"%s\", but it still has a "
"parent \"%s\".\nYou need to let the parent manage the "
"object instead of unreffing the object directly.\n",
GST_OBJECT_NAME (object), GST_OBJECT_NAME (parent));
GST_OBJECT_UNLOCK (object);
object = gst_object_ref (object);
return;
}
} }
/* finalize is called when the object has to free its resources */ /* finalize is called when the object has to free its resources */