group: Update priority when a child is removed

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/93
This commit is contained in:
Thibault Saunier 2020-03-04 17:42:46 -03:00
parent f8091262b5
commit b66290d1be
3 changed files with 58 additions and 2 deletions

View file

@ -565,10 +565,11 @@ _disconnect_signals (GESGroup * group, GESTimelineElement * child,
static void
_child_removed (GESContainer * group, GESTimelineElement * child)
{
GList *children;
GList *children, *tmp;
GstClockTime first_child_start;
gchar *signals_ids_key;
ChildSignalIds *sigids;
guint32 new_priority = G_MAXUINT32;
GESGroupPrivate *priv = GES_GROUP (group)->priv;
_ges_container_sort_children (group);
@ -588,8 +589,15 @@ _child_removed (GESContainer * group, GESTimelineElement * child)
return;
}
for (tmp = children; tmp; tmp = tmp->next)
new_priority =
MIN (new_priority, ges_timeline_element_get_priority (tmp->data));
priv->setting_value = TRUE;
ELEMENT_SET_FLAG (group, GES_TIMELINE_ELEMENT_SET_SIMPLE);
if (_PRIORITY (group) != new_priority)
ges_timeline_element_set_priority (GES_TIMELINE_ELEMENT (group),
new_priority);
first_child_start = GES_TIMELINE_ELEMENT_START (children->data);
if (first_child_start > GES_TIMELINE_ELEMENT_START (group)) {
group->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES;

View file

@ -198,6 +198,8 @@ class GESSimpleTimelineTest(GESTest):
return clip
def append_clip(self, layer=0):
while len(self.timeline.get_layers()) < layer + 1:
self.timeline.append_layer()
layer = self.timeline.get_layers()[layer]
clip = GES.TestClip()
clip.props.start = layer.get_duration()

View file

@ -358,4 +358,50 @@ class TestGroup(common.GESSimpleTimelineTest):
(GES.TestClip, 20, 10),
(GES.TestClip, 30, 10),
],
], groups=[group_clips])
], groups=[group_clips])
def test_group_priority(self):
self.track_types = [GES.TrackType.AUDIO]
self.setUp()
clip0 = self.append_clip()
clip1 = self.append_clip(1)
clip1.props.start = 20
group = GES.Group.new()
group.add(clip0)
group.add(clip1)
self.assertEqual(group.get_layer_priority(), 0)
self.assertTimelineTopology([
[
(GES.TestClip, 0, 10),
],
[
(GES.TestClip, 20, 10),
]
], groups=[(clip0, clip1)])
group.remove(clip0)
self.assertEqual(group.get_layer_priority(), 1)
clip1.edit(self.timeline.get_layers(), 2, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, clip1.start)
self.assertTimelineTopology([
[
(GES.TestClip, 0, 10),
],
[ ],
[
(GES.TestClip, 20, 10),
]
], groups=[(clip1,)])
self.assertEqual(group.get_layer_priority(), 2)
self.assertTrue(clip1.edit(self.timeline.get_layers(), 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, clip1.start))
self.assertTimelineTopology([
[
(GES.TestClip, 0, 10),
(GES.TestClip, 20, 10),
],
[ ],
[ ]
], groups=[(clip1,)])