From f119e93b47efb06ffc68c01d3e094d5346c30041 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 15 May 2017 18:58:38 +0300 Subject: [PATCH] gst: Clear floating flag in constructor of all GstObject subclasses that are not owned by any parent I.e. most of them unfortunately. https://bugzilla.gnome.org/show_bug.cgi?id=743062 --- gst/gstbufferpool.c | 5 ++++- gst/gstdevicemonitor.c | 11 +++++++++-- gst/gststreamcollection.c | 12 ++++++++++-- gst/gststreams.c | 11 +++++++++-- gst/gsttracerrecord.c | 6 +++++- gst/gsttracerutils.c | 10 ++++++++-- libs/gst/net/gstnettimeprovider.c | 5 ++++- 7 files changed, 49 insertions(+), 11 deletions(-) diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index 9529208..3d91236 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -212,7 +212,7 @@ gst_buffer_pool_finalize (GObject * object) * * Creates a new #GstBufferPool instance. * - * Returns: (transfer floating): a new #GstBufferPool instance + * Returns: (transfer full): a new #GstBufferPool instance */ GstBufferPool * gst_buffer_pool_new (void) @@ -222,6 +222,9 @@ gst_buffer_pool_new (void) result = g_object_new (GST_TYPE_BUFFER_POOL, NULL); GST_DEBUG_OBJECT (result, "created new buffer pool"); + /* Clear floating flag */ + gst_object_ref_sink (result); + return result; } diff --git a/gst/gstdevicemonitor.c b/gst/gstdevicemonitor.c index 123d284..add267e 100644 --- a/gst/gstdevicemonitor.c +++ b/gst/gstdevicemonitor.c @@ -785,14 +785,21 @@ gst_device_monitor_remove_filter (GstDeviceMonitor * monitor, guint filter_id) * * Create a new #GstDeviceMonitor * - * Returns: (transfer floating): a new device monitor. + * Returns: (transfer full): a new device monitor. * * Since: 1.4 */ GstDeviceMonitor * gst_device_monitor_new (void) { - return g_object_new (GST_TYPE_DEVICE_MONITOR, NULL); + GstDeviceMonitor *monitor; + + monitor = g_object_new (GST_TYPE_DEVICE_MONITOR, NULL); + + /* Clear floating flag */ + gst_object_ref_sink (monitor); + + return monitor; } /** diff --git a/gst/gststreamcollection.c b/gst/gststreamcollection.c index c1d4674..ef134b9 100644 --- a/gst/gststreamcollection.c +++ b/gst/gststreamcollection.c @@ -184,15 +184,23 @@ gst_stream_collection_finalize (GObject * object) * * Create a new #GstStreamCollection. * - * Returns: (transfer floating): The new #GstStreamCollection. + * Returns: (transfer full): The new #GstStreamCollection. * * Since: 1.10 */ GstStreamCollection * gst_stream_collection_new (const gchar * upstream_id) { - return g_object_new (GST_TYPE_STREAM_COLLECTION, "upstream-id", upstream_id, + GstStreamCollection *collection; + + collection = + g_object_new (GST_TYPE_STREAM_COLLECTION, "upstream-id", upstream_id, NULL); + + /* Clear floating flag */ + g_object_ref_sink (collection); + + return collection; } static void diff --git a/gst/gststreams.c b/gst/gststreams.c index 8873aad..f90d771 100644 --- a/gst/gststreams.c +++ b/gst/gststreams.c @@ -210,7 +210,7 @@ gst_stream_finalize (GObject * object) * Create a new #GstStream for the given @stream_id, @caps, @type * and @flags * - * Returns: (transfer floating): The new #GstStream + * Returns: (transfer full): The new #GstStream * * Since: 1.10 */ @@ -218,8 +218,15 @@ GstStream * gst_stream_new (const gchar * stream_id, GstCaps * caps, GstStreamType type, GstStreamFlags flags) { - return g_object_new (GST_TYPE_STREAM, "stream-id", stream_id, "caps", caps, + GstStream *stream; + + stream = g_object_new (GST_TYPE_STREAM, "stream-id", stream_id, "caps", caps, "stream-type", type, "stream-flags", flags, NULL); + + /* Clear floating flag */ + gst_object_ref_sink (stream); + + return stream; } static void diff --git a/gst/gsttracerrecord.c b/gst/gsttracerrecord.c index 889479d..2446a6e 100644 --- a/gst/gsttracerrecord.c +++ b/gst/gsttracerrecord.c @@ -178,7 +178,7 @@ gst_tracer_record_init (GstTracerRecord * self) * * > Please note that this is still under discussion and subject to change. * - * Returns: (transfer floating): a new #GstTracerRecord + * Returns: (transfer full): a new #GstTracerRecord */ GstTracerRecord * gst_tracer_record_new (const gchar * name, const gchar * firstfield, ...) @@ -219,6 +219,10 @@ gst_tracer_record_new (const gchar * name, const gchar * firstfield, ...) va_end (varargs); self = g_object_new (GST_TYPE_TRACER_RECORD, NULL); + + /* Clear floating flag */ + gst_object_ref_sink (self); + self->spec = structure; gst_tracer_record_build_format (self); diff --git a/gst/gsttracerutils.c b/gst/gsttracerutils.c index c778600..0539869 100644 --- a/gst/gsttracerutils.c +++ b/gst/gsttracerutils.c @@ -114,12 +114,18 @@ _priv_gst_tracing_init (void) if ((feature = gst_registry_lookup_feature (registry, t[i]))) { factory = GST_TRACER_FACTORY (gst_plugin_feature_load (feature)); if (factory) { + GstTracer *tracer; + GST_INFO_OBJECT (factory, "creating tracer: type-id=%u", (guint) factory->type); + tracer = g_object_new (factory->type, "params", params, NULL); + + /* Clear floating flag */ + gst_object_ref_sink (tracer); + /* tracers register them self to the hooks */ - gst_object_unref (g_object_new (factory->type, "params", params, - NULL)); + gst_object_unref (tracer); } else { GST_WARNING_OBJECT (feature, "loading plugin containing feature %s failed!", t[i]); diff --git a/libs/gst/net/gstnettimeprovider.c b/libs/gst/net/gstnettimeprovider.c index 0c0ef69..f8e0308 100644 --- a/libs/gst/net/gstnettimeprovider.c +++ b/libs/gst/net/gstnettimeprovider.c @@ -434,7 +434,7 @@ gst_net_time_provider_initable_iface_init (gpointer g_iface) * * Allows network clients to get the current time of @clock. * - * Returns: (transfer floating): the new #GstNetTimeProvider, or NULL on error + * Returns: (transfer full): the new #GstNetTimeProvider, or NULL on error */ GstNetTimeProvider * gst_net_time_provider_new (GstClock * clock, const gchar * address, gint port) @@ -448,5 +448,8 @@ gst_net_time_provider_new (GstClock * clock, const gchar * address, gint port) g_initable_new (GST_TYPE_NET_TIME_PROVIDER, NULL, NULL, "clock", clock, "address", address, "port", port, NULL); + /* Clear floating flag */ + g_object_ref_sink (ret); + return ret; } -- 2.7.4