From 11887e005879c4ed07008ef4d35eb6df4a60c15d Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 20 Dec 2010 12:00:06 +0100 Subject: [PATCH] GESTimelineLayer: Subclass from GInitiallyUnowned The floating reference will be owned by the Timeline --- ges/ges-timeline-layer.c | 2 +- ges/ges-timeline-layer.h | 4 ++-- ges/ges-timeline.c | 2 +- tests/check/ges/layer.c | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ges/ges-timeline-layer.c b/ges/ges-timeline-layer.c index b4790132d0..ce8249a8e7 100644 --- a/ges/ges-timeline-layer.c +++ b/ges/ges-timeline-layer.c @@ -33,7 +33,7 @@ #include "ges-timeline-layer.h" #include "ges.h" -G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_OBJECT); +G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_INITIALLY_UNOWNED); struct _GESTimelineLayerPrivate { diff --git a/ges/ges-timeline-layer.h b/ges/ges-timeline-layer.h index 4f827af9bc..821fc910f9 100644 --- a/ges/ges-timeline-layer.h +++ b/ges/ges-timeline-layer.h @@ -50,7 +50,7 @@ typedef struct _GESTimelineLayerPrivate GESTimelineLayerPrivate; * @timeline: the #GESTimeline where this layer is being used. */ struct _GESTimelineLayer { - GObject parent; + GInitiallyUnowned parent; /*< public >*/ @@ -74,7 +74,7 @@ struct _GESTimelineLayer { */ struct _GESTimelineLayerClass { /*< private >*/ - GObjectClass parent_class; + GInitiallyUnownedClass parent_class; /*< public >*/ /* virtual methods for subclasses */ diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 5bc037ed25..e13f920992 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -608,7 +608,7 @@ ges_timeline_add_layer (GESTimeline * timeline, GESTimelineLayer * layer) return FALSE; } - /* Reference is stolen */ + g_object_ref_sink (layer); timeline->layers = g_list_append (timeline->layers, layer); /* Inform the layer that it belongs to a new timeline */ diff --git a/tests/check/ges/layer.c b/tests/check/ges/layer.c index 315fa75045..7fbcb7549f 100644 --- a/tests/check/ges/layer.c +++ b/tests/check/ges/layer.c @@ -73,7 +73,11 @@ GST_START_TEST (test_layer_properties) /* The default priority is 0 */ fail_unless_equals_int (ges_timeline_layer_get_priority (layer), 0); + /* Layers are initially floating, once we add them to the timeline, + * the timeline will take that reference. */ + fail_unless (g_object_is_floating (layer)); fail_unless (ges_timeline_add_layer (timeline, layer)); + fail_if (g_object_is_floating (layer)); track = ges_track_new (GES_TRACK_TYPE_CUSTOM, GST_CAPS_ANY); fail_unless (track != NULL);