clip: only allow children with the same timeline
authorHenry Wilkes <hwilkes@igalia.com>
Tue, 10 Mar 2020 11:53:09 +0000 (11:53 +0000)
committerHenry Wilkes <hwilkes@igalia.com>
Mon, 16 Mar 2020 14:19:52 +0000 (14:19 +0000)
Refuse the addition of children whose timeline is neither NULL nor the
clip's timeline.

ges/ges-clip.c
tests/check/ges/clip.c

index 11b58ee63d2645625452bf45f97a187aa679a491..52d7578b92d2f709b83e054106766d53c3649721 100644 (file)
@@ -486,6 +486,15 @@ _add_child (GESContainer * container, GESTimelineElement * element)
 
   g_return_val_if_fail (GES_IS_TRACK_ELEMENT (element), FALSE);
 
+  if (element->timeline
+      && element->timeline != GES_TIMELINE_ELEMENT_TIMELINE (container)) {
+    GST_WARNING_OBJECT (container, "Can not add the child %" GES_FORMAT
+        " because its timeline is %" GST_PTR_FORMAT " rather than the "
+        "clip's timeline %" GST_PTR_FORMAT, GES_ARGS (element),
+        element->timeline, GES_TIMELINE_ELEMENT_TIMELINE (container));
+    return FALSE;
+  }
+
   /* NOTE: notifies are currently frozen by ges_container_add */
   _get_priority_range (container, &min_prio, &max_prio);
   if (ELEMENT_FLAG_IS_SET (element, GES_TRACK_ELEMENT_IS_CORE)) {
index 0cc00ccb285d3b73b8ddfef87d913c98cb9b527e..16ded049b808c4dbd5aa0f9760193d4b548cd0ab 100644 (file)
@@ -588,6 +588,12 @@ GST_START_TEST (test_clip_find_track_element)
   fail_unless (ges_timeline_add_track (timeline, track1));
   fail_unless (ges_timeline_add_track (timeline, track2));
 
+  /* need to register the clip with the timeline */
+  /* FIXME: we should make the clip part of a layer, but the current
+   * default select-tracks-for-object signal is broken for multiple
+   * tracks. In fact, we should be using this signal in this test */
+  ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (clip), timeline);
+
   effect = GES_TRACK_ELEMENT (ges_effect_new ("identity"));
   fail_unless (ges_track_add_element (track, effect));
   fail_unless (ges_container_add (GES_CONTAINER (clip),