[pitivi/1.0] undo: Timeline should be commited after splitting



commit 72a204517ac06fef42688bb11f55ee97a8b7f55e
Author: Thibault Saunier <tsaunier igalia com>
Date:   Wed Mar 13 09:31:55 2019 -0300

    undo: Timeline should be commited after splitting
    
    And do not commit in ClipAction as the commiting needs to be handled at
    the action log level

 pitivi/timeline/timeline.py |  3 ++-
 pitivi/undo/timeline.py     | 21 +++++++++++----------
 2 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index d70949b4..dc46c44f 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1764,7 +1764,8 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         If clips are selected, split them at the current playhead position.
         Otherwise, split all clips at the playhead position.
         """
-        with self.app.action_log.started("split clip", toplevel=True):
+        with self.app.action_log.started("split clip", toplevel=True,
+                    finalizing_action=CommitTimelineFinalizingAction(self._project.pipeline)):
             self._splitElements(self.timeline.selection.selected)
 
     def _splitElements(self, clips=None):
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 4b79004c..feb5398b 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -287,19 +287,20 @@ class ClipAction(UndoableAction):
     def add(self):
         self.clip.set_name(None)
         children = self.clip.get_children(False)
-        self.layer.add_clip(self.clip)
-        # GES adds children if the clip had none. Make sure they are removed.
-        for child in self.clip.get_children(False):
-            if child not in children:
-                self.clip.remove(child)
-        self.layer.get_timeline().get_asset().pipeline.commit_timeline()
-
-    def _child_added_cb(self, clip, track_element):
-        clip.remove(track_element)
+        def child_added_cb(clip, elem):
+            if elem not in children:
+                clip.remove(elem)
+                GObject.signal_stop_emission_by_name(clip, "child-added")
+
+        self.clip.connect("child-added", child_added_cb)
+        try:
+            res = self.layer.add_clip(self.clip)
+            assert(res)
+        finally:
+            self.clip.disconnect_by_func(child_added_cb)
 
     def remove(self):
         self.layer.remove_clip(self.clip)
-        self.layer.get_timeline().get_asset().pipeline.commit_timeline()
 
 
 class ClipAdded(ClipAction):


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