ges: Add guards to all API calls in GESTimelineObject
authorThibault Saunier <thibault.saunier@collabora.com>
Wed, 7 Dec 2011 23:50:13 +0000 (20:50 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 11 Jan 2012 14:56:16 +0000 (11:56 -0300)
And reindent the .h file

ges/ges-timeline-object.c
ges/ges-timeline-object.h

index 62416d15620b864c9a1c77cc99263e399782d1dc..91ecb98c50c3e30d78908cb40e9a6b84ad4a5581 100644 (file)
@@ -406,6 +406,9 @@ ges_timeline_object_create_track_object (GESTimelineObject * object,
   GESTimelineObjectClass *class;
   GESTrackObject *res;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
+  g_return_val_if_fail (GES_IS_TRACK (track), NULL);
+
   class = GES_TIMELINE_OBJECT_GET_CLASS (object);
 
   if (G_UNLIKELY (class->create_track_object == NULL)) {
@@ -438,6 +441,9 @@ ges_timeline_object_create_track_objects (GESTimelineObject * object,
 {
   GESTimelineObjectClass *klass;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+  g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
+
   klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
 
   if (!(klass->create_track_objects)) {
@@ -492,6 +498,9 @@ ges_timeline_object_add_track_object (GESTimelineObject * object, GESTrackObject
   gboolean is_effect = GES_IS_TRACK_EFFECT (trobj);
   GESTimelineObjectClass *klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+  g_return_val_if_fail (GES_IS_TRACK_OBJECT (trobj), FALSE);
+
   GST_LOG ("Got a TrackObject : %p , setting the timeline object as its"
       "creator. Is a TrackEffect %i", trobj, is_effect);
 
@@ -601,6 +610,9 @@ ges_timeline_object_release_track_object (GESTimelineObject * object,
   ObjectMapping *mapping = NULL;
   GESTimelineObjectClass *klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+  g_return_val_if_fail (GES_IS_TRACK_OBJECT (trackobject), FALSE);
+
   GST_DEBUG ("object:%p, trackobject:%p", object, trackobject);
 
   if (!(g_list_find (object->priv->trackobjects, trackobject))) {
@@ -720,6 +732,8 @@ ges_timeline_object_set_start_internal (GESTimelineObject * object,
   GESTrackObject *tr;
   ObjectMapping *map;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+
   GST_DEBUG ("object:%p, start:%" GST_TIME_FORMAT,
       object, GST_TIME_ARGS (start));
 
@@ -769,6 +783,8 @@ ges_timeline_object_set_inpoint_internal (GESTimelineObject * object,
   GList *tmp;
   GESTrackObject *tr;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+
   GST_DEBUG ("object:%p, inpoint:%" GST_TIME_FORMAT,
       object, GST_TIME_ARGS (inpoint));
 
@@ -810,6 +826,8 @@ ges_timeline_object_set_duration_internal (GESTimelineObject * object,
   GList *tmp;
   GESTrackObject *tr;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+
   GST_DEBUG ("object:%p, duration:%" GST_TIME_FORMAT,
       object, GST_TIME_ARGS (duration));
 
@@ -850,11 +868,14 @@ ges_timeline_object_set_priority_internal (GESTimelineObject * object,
   GList *tmp;
   GESTrackObject *tr;
   ObjectMapping *map;
-  GESTimelineObjectPrivate *priv = object->priv;
+  GESTimelineObjectPrivate *priv;
   guint32 layer_min_gnl_prio, layer_max_gnl_prio;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+
   GST_DEBUG ("object:%p, priority:%" G_GUINT32_FORMAT, object, priority);
 
+  priv = object->priv;
   priv->ignore_notifies = TRUE;
 
   object->priv->ignore_notifies = TRUE;
@@ -909,6 +930,8 @@ void
 ges_timeline_object_set_moving_from_layer (GESTimelineObject * object,
     gboolean is_moving)
 {
+  g_return_if_fail (GES_IS_TRACK_OBJECT (object));
+
   object->priv->is_moving = is_moving;
 }
 
@@ -945,7 +968,12 @@ ges_timeline_object_move_to_layer (GESTimelineObject * object, GESTimelineLayer
     * layer)
 {
   gboolean ret;
-  GESTimelineLayer *current_layer = object->priv->layer;
+  GESTimelineLayer *current_layer;
+
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+  g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
+
+  current_layer = object->priv->layer;
 
   if (current_layer == NULL) {
     GST_DEBUG ("Not moving %p, only adding it to %p", object, layer);
@@ -1125,6 +1153,8 @@ ges_timeline_object_get_top_effects (GESTimelineObject * object)
   GList *tmp, *ret;
   guint i;
 
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
+
   ret = NULL;
 
   for (tmp = object->priv->trackobjects, i = 0; i < object->priv->nb_effects;
@@ -1151,6 +1181,8 @@ gint
 ges_timeline_object_get_top_effect_position (GESTimelineObject * object,
     GESTrackEffect * effect)
 {
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), -1);
+
   return find_object_mapping (object,
       GES_TRACK_OBJECT (effect))->priority_offset;
 }
@@ -1172,12 +1204,18 @@ gboolean
 ges_timeline_object_set_top_effect_priority (GESTimelineObject * object,
     GESTrackEffect * effect, guint newpriority)
 {
-  GList *tmp;
   gint inc;
-  GESTrackObject *tck_obj = GES_TRACK_OBJECT (effect);
-  GESTimelineObjectPrivate *priv = object->priv;
+  GList *tmp;
+  guint current_prio;
+  GESTrackObject *tck_obj;
+  GESTimelineObjectPrivate *priv;
+
+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
+
+  tck_obj = GES_TRACK_OBJECT (effect);
+  priv = object->priv;
+  current_prio = ges_track_object_get_priority (tck_obj);
 
-  guint current_prio = ges_track_object_get_priority (tck_obj);
   /*  We don't change the priority */
   if (current_prio == newpriority ||
       (G_UNLIKELY (ges_track_object_get_timeline_object (tck_obj) != object)))
index 3c707ff43b8b1c68552b2bb1b8c835b59fafbec9..2809dc89202433259a22fe4c3e794ee533f1e549 100644 (file)
@@ -211,68 +211,67 @@ struct _GESTimelineObjectClass {
   gpointer _ges_reserved[GES_PADDING - 2];
 };
 
-GType ges_timeline_object_get_type (void);
+GType ges_timeline_object_get_type          (void);
 
 /* Setters */
-void ges_timeline_object_set_start    (GESTimelineObject * object,
+void ges_timeline_object_set_start          (GESTimelineObject * object,
                                       guint64 start);
-void ges_timeline_object_set_inpoint  (GESTimelineObject * object,
+void ges_timeline_object_set_inpoint        (GESTimelineObject * object,
                                       guint64 inpoint);
-void ges_timeline_object_set_duration (GESTimelineObject * object,
+void ges_timeline_object_set_duration       (GESTimelineObject * object,
                                       guint64 duration);
-void ges_timeline_object_set_priority (GESTimelineObject * object,
+void ges_timeline_object_set_priority       (GESTimelineObject * object,
                                       guint priority);
 
-void ges_timeline_object_set_layer    (GESTimelineObject * object,
+void ges_timeline_object_set_layer          (GESTimelineObject * object,
                                       GESTimelineLayer * layer);
 
 /* TrackObject handling */
 GESTrackObject *
-ges_timeline_object_create_track_object  (GESTimelineObject * object,
+ges_timeline_object_create_track_object     (GESTimelineObject * object,
                                          GESTrack * track);
 
 gboolean
-ges_timeline_object_create_track_objects (GESTimelineObject * object,
+ges_timeline_object_create_track_objects    (GESTimelineObject * object,
                                          GESTrack * track);
 
 gboolean
-ges_timeline_object_release_track_object (GESTimelineObject * object,
+ges_timeline_object_release_track_object    (GESTimelineObject * object,
                                          GESTrackObject * trackobject);
 
 gboolean
-ges_timeline_object_fill_track_object    (GESTimelineObject * object,
-                                         GESTrackObject * trackobj,
-                                         GstElement * gnlobj);
+ges_timeline_object_fill_track_object       (GESTimelineObject * object,
+                                         GESTrackObject * trackobj, GstElement * gnlobj);
 
 GESTrackObject *
-ges_timeline_object_find_track_object    (GESTimelineObject * object,
+ges_timeline_object_find_track_object       (GESTimelineObject * object,
                                          GESTrack * track, GType type);
 
 GList *
-ges_timeline_object_get_track_objects    (GESTimelineObject *object);
+ges_timeline_object_get_track_objects       (GESTimelineObject *object);
 
 gboolean
-ges_timeline_object_add_track_object     (GESTimelineObject *object,
+ges_timeline_object_add_track_object        (GESTimelineObject *object,
                                          GESTrackObject *trobj);
 
 /* Layer */
 GESTimelineLayer *
-ges_timeline_object_get_layer            (GESTimelineObject *object);
+ges_timeline_object_get_layer               (GESTimelineObject *object);
 
 gboolean
-ges_timeline_object_move_to_layer        (GESTimelineObject *object,
+ges_timeline_object_move_to_layer           (GESTimelineObject *object,
                                             GESTimelineLayer *layer);
 
 gboolean
-ges_timeline_object_is_moving_from_layer (GESTimelineObject *object);
+ges_timeline_object_is_moving_from_layer    (GESTimelineObject *object);
 
 void
-ges_timeline_object_set_moving_from_layer (GESTimelineObject * object,
+ges_timeline_object_set_moving_from_layer   (GESTimelineObject * object,
                                             gboolean is_moving);
 
 /* Effects */
 GList *
-ges_timeline_object_get_top_effects      (GESTimelineObject *object);
+ges_timeline_object_get_top_effects         (GESTimelineObject *object);
 
 gint 
 ges_timeline_object_get_top_effect_position (GESTimelineObject *object,
@@ -284,14 +283,14 @@ ges_timeline_object_set_top_effect_priority (GESTimelineObject *object,
                                             guint newpriority);
 
 GESTrackType
-ges_timeline_object_get_supported_formats (GESTimelineObject * self);
+ges_timeline_object_get_supported_formats   (GESTimelineObject * object);
 
 void
-ges_timeline_object_set_supported_formats (GESTimelineObject * self,
+ges_timeline_object_set_supported_formats   (GESTimelineObject * object,
                                            GESTrackType supportedformats);
 
 GESTimelineObject *
-ges_timeline_object_split(GESTimelineObject * self, gint64 position);
+ges_timeline_object_split                   (GESTimelineObject * object, gint64 position);
 
 void
 ges_timeline_object_objects_set_locked      (GESTimelineObject * object, gboolean locked);