element: Enforce that elements created by gst_element_factory_create/make() are floating
authorSebastian Dröge <sebastian@centricular.com>
Thu, 12 Sep 2019 07:09:18 +0000 (10:09 +0300)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 14 Sep 2019 23:26:54 +0000 (00:26 +0100)
Bindings might have a hard time making sure that the reference is indeed
still floating after returning here.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444

gst/gstelementfactory.c

index cf3b100..3ccfc14 100644 (file)
@@ -386,6 +386,12 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
     /* This ref will never be dropped as the class is never destroyed */
     GST_OBJECT_FLAG_SET (factory, GST_OBJECT_FLAG_MAY_BE_LEAKED);
 
+  /* Ensure that the reference is floating. Bindings might have a hard time
+   * making sure that the reference is indeed still floating after returning
+   * here */
+  if (element)
+    g_object_force_floating ((GObject *) element);
+
   GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory));
 
   return element;