container: Handle children pasting failures
authorThibault Saunier <tsaunier@igalia.com>
Sun, 26 May 2019 00:20:07 +0000 (20:20 -0400)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 14 Aug 2019 22:37:58 +0000 (23:37 +0100)
ges/ges-container.c
tests/check/python/test_timeline.py

index 07a5afa..9a30a85 100644 (file)
@@ -348,6 +348,15 @@ _paste (GESTimelineElement * element, GESTimelineElement * ref,
     nchild =
         ges_timeline_element_paste (map->child,
         paste_position - map->start_offset);
+
+    if (!nchild) {
+      while (ncontainer->children)
+        ges_container_remove (ncontainer, ncontainer->children->data);
+
+      g_object_unref (ncontainer);
+      return NULL;
+    }
+
     ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (ncontainer),
         GES_TIMELINE_ELEMENT_TIMELINE (ref));
     ges_container_add (ncontainer, nchild);
index 95f9f7c..4a02c4e 100644 (file)
@@ -721,6 +721,21 @@ class TestInvalidOverlaps(common.GESSimpleTimelineTest):
             ],
         ])
 
+        group = GES.Group.new()
+        group.add(clip)
+
+        copied_group = group.copy(True)
+        self.assertFalse(copied_group.paste(group.props.start))
+        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()