g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
+ g_return_val_if_fail (GST_ELEMENT_CAST (bin) != element, FALSE);
bclass = GST_BIN_GET_CLASS (bin);
GST_DEBUG_OBJECT (bin, "element :%s", GST_ELEMENT_NAME (element));
+ /* we obviously can't remove ourself from ourself */
+ if (G_UNLIKELY (element == GST_ELEMENT_CAST (bin)))
+ goto removing_itself;
+
GST_OBJECT_LOCK (bin);
GST_OBJECT_LOCK (element);
return TRUE;
/* ERROR handling */
+removing_itself:
+ {
+ GST_OBJECT_LOCK (bin);
+ g_warning ("Cannot remove bin '%s' from itself", GST_ELEMENT_NAME (bin));
+ GST_OBJECT_UNLOCK (bin);
+ return FALSE;
+ }
not_in_bin:
{
g_warning ("Element '%s' is not in bin '%s'", elem_name,
g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
+ g_return_val_if_fail (GST_ELEMENT_CAST (bin) != element, FALSE);
bclass = GST_BIN_GET_CLASS (bin);
bin = gst_bin_new (NULL);
fail_unless (bin != NULL, "Could not create bin");
- ASSERT_WARNING (gst_bin_add (GST_BIN (bin), bin));
+ ASSERT_CRITICAL (gst_bin_add (GST_BIN (bin), bin));
gst_object_unref (bin);
}