group: incorrect `timeline` of children
Currently, you can add clips from different timelines to the same GESGroup
. This can lead to a difference in the timeline
of a group and its children:
>>> timeline = GES.Timeline.new()
>>> alt_timeline = GES.Timeline.new()
>>> layer = timeline.append_layer()
>>> alt_layer = alt_timeline.append_layer()
>>> asset = GES.Asset.request(GES.TestClip, None)
>>> clip = layer.add_asset(asset, 0, 0, 10, GES.TrackType.AUDIO)
>>> alt_clip = alt_layer.add_asset(asset, 30, 0, 10, GES.TrackType.AUDIO)
>>> group = GES.Group.new()
>>> group.add(clip)
True
>>> group.add(alt_clip)
True
>>> group.timeline is clip.timeline
True
>>> group.timeline is alt_clip.timeline
False
This can obviously lead to problems. Similarly, when a group contains a clip, and neither have a timeline, then we can get a critical failure when we add the clip to a timeline because the timeline is not tracking the clip's parent: the group.
>>> timeline = GES.Timeline.new()
>>> layer = timeline.append_layer()
>>> clip = GES.TestClip.new()
>>> group = GES.Group.new()
>>> group.add(clip)
True
>>> clip.set_duration(20)
True
>>> layer.add_clip(clip)
**
GES:ERROR:ges-timeline-tree.c:205:timeline_tree_track_element: assertion failed: (parent)
Bail out! GES:ERROR:ges-timeline-tree.c:205:timeline_tree_track_element: assertion failed: (parent)
Aborted (core dumped)
I propose that you can only add to a group elements that have a timeline
set. If it is the first element, we set the group's timeline
to the same value. Otherwise, it must match the timeline
of the group. And if, and only if, the group is empty, it will have a NULL
timeline. To keep this consistent, when a clip is removed from its layer, and its timeline, we should automatically remove it from the group.