From: Edward Hervey Date: Mon, 20 Dec 2010 10:58:21 +0000 (+0100) Subject: GESTrackObject: Subclass from GInitiallyUnowned X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=752e6cfb757aa1082406d8e28522e003cd935236;p=platform%2Fupstream%2Fgst-editing-services.git GESTrackObject: Subclass from GInitiallyUnowned The floating reference will be owned by the Track --- diff --git a/ges/ges-track-object.c b/ges/ges-track-object.c index 5bf8bb2..5e044dc 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 a0713e0..7371df3 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 474a465..dea2b83 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; }