From e79def14a5c47ef7c3660e17fd183d25dc82ae3f Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 10 Dec 2019 13:31:50 +0100 Subject: [PATCH] device, elementfactory: relax floating requirement 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 | 7 ++++--- gst/gstelementfactory.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gst/gstdevice.c b/gst/gstdevice.c index bb7f303b53..8f31ffe875 100644 --- a/gst/gstdevice.c +++ b/gst/gstdevice.c @@ -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; diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 5d457f1090..49aaa97cf6 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -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));