bin: Don't check twice for adding a bin to itself or removing it from itself
authorSebastian Dröge <sebastian@centricular.com>
Mon, 8 Nov 2021 13:28:06 +0000 (15:28 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 8 Nov 2021 20:31:44 +0000 (20:31 +0000)
This is already covered by a `g_return_val_if_fail()` in the calling
function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1320>

subprojects/gstreamer/gst/gstbin.c

index 298a8c2..f1d8f5b 100644 (file)
@@ -1166,10 +1166,6 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
 
   GST_DEBUG_OBJECT (bin, "element :%s", GST_ELEMENT_NAME (element));
 
-  /* we obviously can't add ourself to ourself */
-  if (G_UNLIKELY (element == GST_ELEMENT_CAST (bin)))
-    goto adding_itself;
-
   /* get the element name to make sure it is unique in this bin. */
   GST_OBJECT_LOCK (element);
   elem_name = g_strdup (GST_ELEMENT_NAME (element));
@@ -1379,15 +1375,6 @@ no_state_recalc:
   return TRUE;
 
   /* ERROR handling here */
-adding_itself:
-  {
-    GST_OBJECT_LOCK (bin);
-    g_warning ("Cannot add bin '%s' to itself", GST_ELEMENT_NAME (bin));
-    GST_OBJECT_UNLOCK (bin);
-    gst_object_ref_sink (element);
-    gst_object_unref (element);
-    return FALSE;
-  }
 duplicate_name:
   {
     GST_OBJECT_UNLOCK (bin);
@@ -1575,10 +1562,6 @@ gst_bin_remove_func (GstBin * bin, GstElement * element)
 
   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);
@@ -1834,13 +1817,6 @@ no_state_recalc:
   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:
   {
     GST_OBJECT_UNLOCK (element);