From: Sebastian Dröge Date: Thu, 12 Sep 2019 07:08:39 +0000 (+0300) Subject: device: Enforce that elements created by gst_device_create_element() are floating X-Git-Tag: 1.19.3~1078 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=341ee451558cfcf82cce4c3de1116eed3112f0d5;p=platform%2Fupstream%2Fgstreamer.git device: Enforce that elements created by gst_device_create_element() are floating 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 --- diff --git a/gst/gstdevice.c b/gst/gstdevice.c index 6040782..64f5ba5 100644 --- a/gst/gstdevice.c +++ b/gst/gstdevice.c @@ -205,13 +205,20 @@ GstElement * gst_device_create_element (GstDevice * device, const gchar * name) { GstDeviceClass *klass = GST_DEVICE_GET_CLASS (device); + GstElement *element = NULL; g_return_val_if_fail (GST_IS_DEVICE (device), NULL); if (klass->create_element) - return klass->create_element (device, name); - else - return NULL; + element = klass->create_element (device, name); + + /* 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); + + return element; } /**