[pitivi] project: Fix asset added not undoable



commit 9dc1600243e6e7e98b3cc36ec0ff3b93aa9222d6
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Apr 3 16:36:15 2016 +0200

    project: Fix asset added not undoable
    
    Differential Revision: https://phabricator.freedesktop.org/D864

 pitivi/project.py          |    5 ++++-
 tests/test_undo_project.py |   24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 2800e1d..9cc3308 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -700,7 +700,7 @@ class Project(Loggable, GES.Project):
         self._has_default_video_settings = has_default_settings
 
         # FIXME That does not really belong to here and should be savable into
-        # The serialized file. For now, just let it be here.
+        # the serialized file. For now, just let it be here.
         # A (muxer -> containersettings) map.
         self._containersettings_cache = {}
         # A (vencoder -> vcodecsettings) map.
@@ -1103,6 +1103,9 @@ class Project(Loggable, GES.Project):
         if self.loaded:
             if not asset.get_proxy_target() in self.list_assets(GES.Extractable):
                 self.app.proxy_manager.addJob(asset, asset.force_proxying)
+
+            if not self.loading_assets:
+                self.app.action_log.commit()
         else:
             self.debug("Project still loading, not using proxies: "
                        "%s", asset.props.id)
diff --git a/tests/test_undo_project.py b/tests/test_undo_project.py
index b263136..dd88316 100644
--- a/tests/test_undo_project.py
+++ b/tests/test_undo_project.py
@@ -20,6 +20,8 @@
 # Boston, MA 02110-1301, USA.
 from unittest import TestCase
 
+from gi.repository import GES
+
 from pitivi.application import Pitivi
 from tests import common
 
@@ -47,3 +49,25 @@ class TestProjectUndo(TestCase):
         self.assertFalse(self.action_log.is_in_transaction())
         self.assertFalse(self.action_log.undo_stacks)
 
+    def test_asset_added(self):
+        mainloop = common.create_main_loop()
+
+        def commit_cb(unused_action_log, stack):
+            self.assertEqual(stack.action_group_name, "Adding assets")
+            mainloop.quit()
+
+        self.action_log.connect("commit", commit_cb)
+
+        def loaded_cb(unused_project, unused_timeline):
+            uris = [common.getSampleUri("tears_of_steel.webm")]
+            self.project.addUris(uris)
+
+        self.project.connect_after("loaded", loaded_cb)
+
+        mainloop.run()
+
+        self.assertEqual(len(self.project.list_assets(GES.Extractable)), 1)
+        self.action_log.undo()
+        self.assertEqual(len(self.project.list_assets(GES.Extractable)), 0)
+        self.action_log.redo()
+        self.assertEqual(len(self.project.list_assets(GES.Extractable)), 1)


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