From c0c79188ca5d9f0a2d13ab3940a7e4977410cdca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 3 Jul 2012 00:07:11 +0100 Subject: [PATCH] bus, clock: make sure these never have a floating ref 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 --- gst/gstbus.c | 3 +++ gst/gstclock.c | 3 +++ gst/gstsystemclock.c | 4 +--- tests/check/gst/gstpipeline.c | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gst/gstbus.c b/gst/gstbus.c index 1a82f54..898fc5e 100644 --- a/gst/gstbus.c +++ b/gst/gstbus.c @@ -228,6 +228,9 @@ gst_bus_init (GstBus * bus) 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"); } diff --git a/gst/gstclock.c b/gst/gstclock.c index 3d9e73b..c84700d 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -699,6 +699,9 @@ gst_clock_init (GstClock * clock) 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 diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index 9cac9ee..8385e1a 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -304,9 +304,7 @@ gst_system_clock_obtain (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); diff --git a/tests/check/gst/gstpipeline.c b/tests/check/gst/gstpipeline.c index 899c017..4e34eea 100644 --- a/tests/check/gst/gstpipeline.c +++ b/tests/check/gst/gstpipeline.c @@ -125,6 +125,9 @@ GST_START_TEST (test_get_bus) 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); -- 2.7.4