mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
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
This commit is contained in:
parent
b0202ed22b
commit
1e5bb2edf6
2 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue