device, elementfactory: relax floating requirement
authorMathieu Duponchelle <mathieu@centricular.com>
Tue, 10 Dec 2019 12:31:50 +0000 (13:31 +0100)
committerMathieu Duponchelle <mathieu@centricular.com>
Tue, 10 Dec 2019 12:31:50 +0000 (13:31 +0100)
Using g_assert() is a bit too extreme, as it will abort the whole
program unless G_DISABLE_ASSERTS is true.

Switch to g_critical()

gst/gstdevice.c
gst/gstelementfactory.c

index bb7f303..8f31ffe 100644 (file)
@@ -212,11 +212,12 @@ gst_device_create_element (GstDevice * device, const gchar * name)
   if (klass->create_element)
     element = klass->create_element (device, name);
 
-  if (element) {
+  if (element && !g_object_is_floating ((GObject *) element)) {
     /* The reference we receive here should be floating, but we can't force
-     * it at our level. Simply assert to make the issue obvious to bindings
+     * it at our level. Simply raise a critical to make the issue obvious to bindings
      * developers */
-    g_assert (g_object_is_floating ((GObject *) element));
+    g_critical ("The created element should be floating, "
+        "this is probably caused by faulty bindings");
   }
 
   return element;
index 5d457f1..49aaa97 100644 (file)
@@ -386,10 +386,14 @@ 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);
 
-  /* The reference we receive here should be floating, but we can't force
-   * it at our level. Simply assert to make the issue obvious to bindings
-   * developers */
-  g_assert (g_object_is_floating ((GObject *) element));
+  if (!g_object_is_floating ((GObject *) element)) {
+    /* The reference we receive here should be floating, but we can't force
+     * it at our level. Simply raise a critical to make the issue obvious to bindings
+     * users / developers */
+    g_critical ("The created element should be floating, "
+        "this is probably caused by faulty bindings");
+  }
+
 
   GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory));