clip: Fix layer managament when copying a clip that was pasted
authorThibault Saunier <tsaunier@igalia.com>
Sat, 25 May 2019 22:51:08 +0000 (18:51 -0400)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 14 Aug 2019 22:37:58 +0000 (23:37 +0100)
ges/ges-clip.c
tests/check/python/test_timeline.py

index 560d685..e8b4fa5 100644 (file)
@@ -665,16 +665,16 @@ _deep_copy (GESTimelineElement * element, GESTimelineElement * copy)
   GList *tmp;
   GESClip *self = GES_CLIP (element), *ccopy = GES_CLIP (copy);
 
+  if (!self->priv->layer)
+    return;
+
   for (tmp = GES_CONTAINER_CHILDREN (element); tmp; tmp = tmp->next) {
     ccopy->priv->copied_track_elements =
         g_list_append (ccopy->priv->copied_track_elements,
         ges_timeline_element_copy (tmp->data, TRUE));
   }
 
-  if (self->priv->copied_layer)
-    ccopy->priv->copied_layer = g_object_ref (self->priv->copied_layer);
-  else if (self->priv->layer)
-    ccopy->priv->copied_layer = g_object_ref (self->priv->layer);
+  ccopy->priv->copied_layer = g_object_ref (self->priv->layer);
 }
 
 static GESTimelineElement *
index 5126f13..95f9f7c 100644 (file)
@@ -691,7 +691,7 @@ class TestInvalidOverlaps(common.GESSimpleTimelineTest):
             ]
         ])
         copy = clip.copy(True)
-        self.assertIsNotNone(copy.paste(copy.props.start + 1))
+        pasted = copy.paste(copy.props.start + 1)
         self.assertTimelineTopology([
             [
                 (GES.TestClip, 0, 10),
@@ -699,6 +699,28 @@ class TestInvalidOverlaps(common.GESSimpleTimelineTest):
             ]
         ])
 
+        pasted.move_to_layer(self.timeline.append_layer())
+        self.assertTimelineTopology([
+            [
+                (GES.TestClip, 0, 10),
+            ],
+            [
+                (GES.TestClip, 1, 10),
+            ]
+        ])
+
+        copy = pasted.copy(True)
+        self.assertIsNotNone(copy.paste(pasted.props.start - 1))
+        self.assertTimelineTopology([
+            [
+                (GES.TestClip, 0, 10),
+            ],
+            [
+                (GES.TestClip, 0, 10),
+                (GES.TestClip, 1, 10),
+            ],
+        ])
+
     def test_move_group_with_overlaping_clips(self):
         self.track_types = [GES.TrackType.AUDIO]
         super().setUp()