diff options
author | Edward Hervey <edward.hervey@collabora.co.uk> | 2010-12-20 11:58:21 +0100 |
---|---|---|
committer | Edward Hervey <edward.hervey@collabora.co.uk> | 2010-12-20 12:03:48 +0100 |
commit | 752e6cfb757aa1082406d8e28522e003cd935236 (patch) | |
tree | 499800fea26a44fbe9606bb94f796df804ca48f7 | |
parent | c90f399bfb7766b7933fc6eb4f96ac2b70a2e339 (diff) |
GESTrackObject: Subclass from GInitiallyUnowned
The floating reference will be owned by the Track
-rw-r--r-- | ges/ges-track-object.c | 3 | ||||
-rw-r--r-- | ges/ges-track-object.h | 4 | ||||
-rw-r--r-- | ges/ges-track.c | 16 |
3 files changed, 17 insertions, 6 deletions
diff --git a/ges/ges-track-object.c b/ges/ges-track-object.c index 5bf8bb2d..5e044dc4 100644 --- a/ges/ges-track-object.c +++ b/ges/ges-track-object.c @@ -34,7 +34,8 @@ #include "ges-track-object.h" #include "ges-timeline-object.h" -G_DEFINE_ABSTRACT_TYPE (GESTrackObject, ges_track_object, G_TYPE_OBJECT); +G_DEFINE_ABSTRACT_TYPE (GESTrackObject, ges_track_object, + G_TYPE_INITIALLY_UNOWNED); struct _GESTrackObjectPrivate { diff --git a/ges/ges-track-object.h b/ges/ges-track-object.h index a0713e06..7371df34 100644 --- a/ges/ges-track-object.h +++ b/ges/ges-track-object.h @@ -78,7 +78,7 @@ typedef struct _GESTrackObjectPrivate GESTrackObjectPrivate; * The GESTrackObject base class. */ struct _GESTrackObject { - GObject parent; + GInitiallyUnowned parent; /*< private >*/ guint64 start; @@ -111,7 +111,7 @@ struct _GESTrackObject { */ struct _GESTrackObjectClass { /*< private >*/ - GObjectClass parent_class; + GInitiallyUnownedClass parent_class; /*< public >*/ /* virtual methods for subclasses */ diff --git a/ges/ges-track.c b/ges/ges-track.c index 474a465d..dea2b83a 100644 --- a/ges/ges-track.c +++ b/ges/ges-track.c @@ -292,9 +292,12 @@ ges_track_set_caps (GESTrack * track, const GstCaps * caps) /** * ges_track_add_object: * @track: a #GESTrack - * @object: the #GESTrackObject to add + * @object: (transfer full): the #GESTrackObject to add * - * Adds the given object to the track. + * Adds the given object to the track. Sets the object's controlling track, + * and thus takes ownership of the @object. + * + * An object can only be added to one track. * * Returns: #TRUE if the object was properly added. #FALSE if the track does not * want to accept the object. @@ -333,6 +336,8 @@ ges_track_add_object (GESTrack * track, GESTrackObject * object) return FALSE; } + g_object_ref_sink (object); + track->priv->trackobjects = g_list_append (track->priv->trackobjects, object); return TRUE; @@ -343,7 +348,10 @@ ges_track_add_object (GESTrack * track, GESTrackObject * object) * @track: a #GESTrack * @object: the #GESTrackObject to remove * - * Removes the object from the track. + * Removes the object from the track and unparents it. + * Unparenting it means the reference owned by @track on the @object will be + * removed. If you wish to use the @object after this function, make sure you + * call g_object_ref() before removing it from the @track. * * Returns: #TRUE if the object was removed, else #FALSE if the track * could not remove the object (like if it didn't belong to the track). @@ -377,6 +385,8 @@ ges_track_remove_object (GESTrack * track, GESTrackObject * object) ges_track_object_set_track (object, NULL); priv->trackobjects = g_list_remove (priv->trackobjects, object); + g_object_unref (object); + return TRUE; } |