[pitivi] timeline: Handle paste not possible



commit 357a0a0936b0646bb6af94db0bb944d4d4e40c4b
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sat Sep 21 02:23:57 2019 +0200

    timeline: Handle paste not possible
    
    Fixes #2325

 pitivi/timeline/timeline.py     |  6 +++++-
 pitivi/undo/timeline.py         |  3 ---
 tests/test_timeline_timeline.py | 12 ++++++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index d285655c..cc7ade76 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1891,11 +1891,15 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             self.info("Nothing to paste.")
             return
 
+        position = self._project.pipeline.getPosition()
         with self.app.action_log.started("paste",
                     finalizing_action=CommitTimelineFinalizingAction(self._project.pipeline),
                     toplevel=True):
-            position = self._project.pipeline.getPosition()
             copied_group_shallow_copy = self.__copied_group.paste(position)
+            if not copied_group_shallow_copy:
+                self.info("The paste is not possible at position: %s", position)
+                return
+
             try:
                 self.__copied_group = copied_group_shallow_copy.copy(True)
                 self.__copied_group.props.serialize = False
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index a2d27e34..cef3f57a 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -19,10 +19,8 @@
 from gi.repository import GES
 from gi.repository import GObject
 from gi.repository import Gst
-from gi.repository import GstController
 
 from pitivi.effects import PROPS_TO_IGNORE
-from pitivi.undo.undo import Action
 from pitivi.undo.undo import FinalizingAction
 from pitivi.undo.undo import GObjectObserver
 from pitivi.undo.undo import MetaContainerObserver
@@ -287,7 +285,6 @@ class ClipAction(UndoableAction):
 
     def add(self):
         self.clip.set_name(None)
-        timeline = self.layer.get_timeline()
         children = self.clip.get_children(False)
 
         def child_added_cb(clip, elem):
diff --git a/tests/test_timeline_timeline.py b/tests/test_timeline_timeline.py
index 20e53b1c..76b4b69d 100644
--- a/tests/test_timeline_timeline.py
+++ b/tests/test_timeline_timeline.py
@@ -564,6 +564,18 @@ class TestCopyPaste(BaseTestTimeline):
         self.assertEqual(copied_clips[2].props.start, position)
         self.assertEqual(copied_clips[3].props.start, position + 10)
 
+    def test_paste_not_possible(self):
+        timeline_container = self.copyClips(1)
+        timeline = timeline_container.timeline
+        layer = timeline.ges_timeline.get_layers()[0]
+        project = timeline.ges_timeline.get_asset()
+        self.assertEqual(len(layer.get_clips()), 1)
+
+        position = 0
+        project.pipeline.getPosition = mock.Mock(return_value=position)
+        timeline_container.paste_action.emit("activate", None)
+        self.assertEqual(len(layer.get_clips()), 1)
+
 
 class TestEditing(BaseTestTimeline):
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]