Clear the initial floating ref in the init function for
busses and clocks. These objects can be set on multiple
elements, so there's no clear parent-child relationship
here. Ideally we'd just not make them derive from
GInitiallyUnowned at all, but since we want to keep
using GstObject features for debugging, we'll just do
it like this.
This should also fix some problems with bindings, which
seem to get confused when they get floating refs from
non-constructor functions (or functions annotated to
have a 'transfer full' return type). This works now:
from gi.repository import GObject, Gst
GObject.threads_init()
Gst.init(None)
pipeline=Gst.Pipeline()
bus = pipeline.get_bus()
pipeline.set_state(Gst.State.NULL)
del pipeline;
https://bugzilla.gnome.org/show_bug.cgi?id=679286
https://bugzilla.gnome.org/show_bug.cgi?id=657202
g_mutex_init (&bus->priv->queue_lock);
bus->priv->queue = gst_atomic_queue_new (32);
+ /* clear floating flag */
+ gst_object_ref_sink (bus);
+
GST_DEBUG_OBJECT (bus, "created");
}
priv->time_index = 0;
priv->timeout = DEFAULT_TIMEOUT;
priv->times = g_new0 (GstClockTime, 4 * priv->window_size);
+
+ /* clear floating flag */
+ gst_object_ref_sink (clock);
}
static void
clock = g_object_new (GST_TYPE_SYSTEM_CLOCK,
"name", "GstSystemClock", NULL);
- /* we created the global clock; take ownership so
- * we can hand out instances later */
- gst_object_ref_sink (clock);
+ g_assert (!g_object_is_floating (G_OBJECT (clock)));
_the_system_clock = clock;
g_mutex_unlock (&_gst_sysclock_mutex);
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after get_bus", 1);
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
+ /* bindings don't like the floating flag to be set here */
+ fail_if (g_object_is_floating (bus));
+
gst_object_unref (pipeline);
ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1);