layer: Resort clips before syncing priorities

We set the priorities making the assumption that `start_clips` is properly
ordered by start!

Fixes https://gitlab.gnome.org/GNOME/pitivi/issues/2254
This commit is contained in:
Thibault Saunier 2019-01-28 18:59:40 -03:00
parent 044c2a2d75
commit dea6f0df98
2 changed files with 20 additions and 0 deletions

View file

@ -234,6 +234,9 @@ ges_layer_resync_priorities_by_type (GESLayer * layer,
GList *tmp;
GESTimelineElement *element;
layer->priv->clips_start =
g_list_sort (layer->priv->clips_start,
(GCompareFunc) element_start_compare);
for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) {
element = GES_TIMELINE_ELEMENT (tmp->data);
@ -783,6 +786,9 @@ ges_layer_get_clips_in_interval (GESLayer * layer, GstClockTime start,
g_return_val_if_fail (GES_IS_LAYER (layer), NULL);
layer->priv->clips_start =
g_list_sort (layer->priv->clips_start,
(GCompareFunc) element_start_compare);
for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) {
clip_intersects = FALSE;
clip_start = ges_timeline_element_get_start (tmp->data);

View file

@ -244,3 +244,17 @@ class TestTransitions(GESSimpleTimelineTest):
# transition and once for the audio transition.
self.assertEqual(
signals, ["notify::start", "clip-added", "clip-added"])
class TestPriorities(GESSimpleTimelineTest):
def test_clips_priorities(self):
clip = self.add_clip(0, 0, 100)
clip1 = self.add_clip(100, 0, 100)
self.timeline.commit()
self.assertLess(clip.props.priority, clip1.props.priority)
clip.props.start = 101
self.timeline.commit()
self.assertGreater(clip.props.priority, clip1.props.priority)