diff options
author | Thibault Saunier <thibault.saunier@collabora.com> | 2013-07-10 23:15:17 -0400 |
---|---|---|
committer | Thibault Saunier <thibault.saunier@collabora.com> | 2013-07-10 23:17:54 -0400 |
commit | 1e5bb2edf62412b553d5b23a8505285989874cdf (patch) | |
tree | 2d0266ffe8131be8e0af8d707d6de5280ed009c1 | |
parent | b0202ed22b2126884299ed2ff3633c64524e1036 (diff) |
timelineelement: Make sure that we will never set a negative start
Currently we can end up overflowing the start of others child of our
parent, avoid that making sure we can set our start to what was
requested by the user before actually doing it
+ Add a test
-rw-r--r-- | ges/ges-timeline-element.c | 12 | ||||
-rw-r--r-- | tests/check/ges/group.c | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/ges/ges-timeline-element.c b/ges/ges-timeline-element.c index 744abf9..67108d1 100644 --- a/ges/ges-timeline-element.c +++ b/ges/ges-timeline-element.c @@ -378,6 +378,7 @@ void ges_timeline_element_set_start (GESTimelineElement * self, GstClockTime start) { GESTimelineElementClass *klass; + GESTimelineElement *toplevel_container; g_return_if_fail (GES_IS_TIMELINE_ELEMENT (self)); @@ -387,6 +388,17 @@ ges_timeline_element_set_start (GESTimelineElement * self, GstClockTime start) " new start: %" GST_TIME_FORMAT, GST_TIME_ARGS (GES_TIMELINE_ELEMENT_START (self)), GST_TIME_ARGS (start)); + toplevel_container = ges_timeline_element_get_toplevel_parent (self); + + if (((gint64) (_START (toplevel_container) + start - _START (self))) < 0) { + GST_INFO_OBJECT (self, "Can not move the object as it would imply its" + "container to have a negative start value"); + + gst_object_unref (toplevel_container); + return; + } + + gst_object_unref (toplevel_container); if (klass->set_start) { if (klass->set_start (self, start)) { self->start = start; diff --git a/tests/check/ges/group.c b/tests/check/ges/group.c index 5644b23..e60b61e 100644 --- a/tests/check/ges/group.c +++ b/tests/check/ges/group.c @@ -69,6 +69,10 @@ GST_START_TEST (test_move_group) ASSERT_OBJECT_REFCOUNT (group, "1 ref for the timeline", 1); fail_unless (g_list_length (GES_CONTAINER_CHILDREN (group)) == 3); assert_equals_int (GES_CONTAINER_HEIGHT (group), 2); + + /* Nothing should move */ + ges_timeline_element_set_start (GES_TIMELINE_ELEMENT (clip1), 5); + CHECK_OBJECT_PROPS (clip, 0, 0, 10); CHECK_OBJECT_PROPS (clip1, 10, 0, 10); CHECK_OBJECT_PROPS (clip2, 50, 0, 60); |