diff --git a/ChangeLog b/ChangeLog index c7e24eebaf..c427730979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-03-22 Wim Taymans + + * 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 * tools/gst-launch.1.in: diff --git a/gst/gstelement.c b/gst/gstelement.c index 3b7911da1b..950e3f1424 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -2423,14 +2423,9 @@ gst_element_dispose (GObject * object) GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose"); - if (GST_STATE (element) != GST_STATE_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; - } + if (GST_STATE (element) != GST_STATE_NULL) + goto not_null; + g_return_if_fail (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING); 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"); 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 diff --git a/gst/gstobject.c b/gst/gstobject.c index cd06105b35..71dc0c8534 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -501,9 +501,13 @@ gst_object_replace (GstObject ** oldobj, GstObject * newobj) static void gst_object_dispose (GObject * object) { + GstObject *parent; + GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose"); GST_OBJECT_LOCK (object); + if ((parent = GST_OBJECT_PARENT (object))) + goto have_parent; GST_OBJECT_PARENT (object) = NULL; GST_OBJECT_UNLOCK (object); @@ -511,6 +515,20 @@ gst_object_dispose (GObject * object) PATCH_REFCOUNT1 (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 */