From bb391a39954225b2f9f617d234bb2f629c0f5518 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 25 May 2019 16:05:00 -0400 Subject: [PATCH] element: Properly handle the fact that pasting can return NULL And fix paste annotation --- ges/ges-clip.c | 1 - ges/ges-timeline-element.c | 5 +++-- tests/check/python/test_timeline.py | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ges/ges-clip.c b/ges/ges-clip.c index 222fdf6..560d685 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -693,7 +693,6 @@ _paste (GESTimelineElement * element, GESTimelineElement * ref, if (!ges_layer_add_clip (self->priv->copied_layer, nclip)) { GST_INFO ("%" GES_FORMAT " could not be pasted to %" GST_TIME_FORMAT, GES_ARGS (element), GST_TIME_ARGS (paste_position)); - gst_object_unref (nclip); return NULL; } diff --git a/ges/ges-timeline-element.c b/ges/ges-timeline-element.c index 28c42a8..5483722 100644 --- a/ges/ges-timeline-element.c +++ b/ges/ges-timeline-element.c @@ -1825,7 +1825,8 @@ ges_timeline_element_get_track_types (GESTimelineElement * self) * using ges_timeline_element_copy with recurse=TRUE set, * otherwise it will fail. * - * Returns: (transfer none): Paste @self copying the element + * Returns: (transfer full): New element resulting of pasting @self + * or %NULL * * Since: 1.6.0 */ @@ -1853,7 +1854,7 @@ ges_timeline_element_paste (GESTimelineElement * self, g_clear_object (&self->priv->copied_from); - return g_object_ref (res); + return res ? g_object_ref (res) : res; } /** diff --git a/tests/check/python/test_timeline.py b/tests/check/python/test_timeline.py index ded93f3..5126f13 100644 --- a/tests/check/python/test_timeline.py +++ b/tests/check/python/test_timeline.py @@ -677,6 +677,28 @@ class TestInvalidOverlaps(common.GESSimpleTimelineTest): ] ]) + def test_copy_paste_overlapping(self): + self.track_types = [GES.TrackType.AUDIO] + super().setUp() + clip = self.append_clip() + + copy = clip.copy(True) + self.assertIsNone(copy.paste(copy.props.start)) + self.assertTimelineTopology([ + [ + (GES.TestClip, 0, 10), + + ] + ]) + copy = clip.copy(True) + self.assertIsNotNone(copy.paste(copy.props.start + 1)) + self.assertTimelineTopology([ + [ + (GES.TestClip, 0, 10), + (GES.TestClip, 1, 10), + ] + ]) + def test_move_group_with_overlaping_clips(self): self.track_types = [GES.TrackType.AUDIO] super().setUp() -- 2.7.4