[pitivi] undo: Reuse the effects cached in Effect*Action
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] undo: Reuse the effects cached in Effect*Action
- Date: Thu, 6 Oct 2016 10:03:01 +0000 (UTC)
commit 7bc60453390ee85b02ee0a93bd10d656632de69b
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Wed Oct 5 02:27:17 2016 +0200
undo: Reuse the effects cached in Effect*Action
No need to recreate the effects. Keep everything in memory.
This way the TrackElementPropertyChanged objects will affect the proper
track element (effect) when redone.
Fixes https://phabricator.freedesktop.org/T7571
Reviewed-by: Thibault Saunier <tsaunier gnome org>
Differential Revision: https://phabricator.freedesktop.org/D1349
pitivi/undo/timeline.py | 4 +---
tests/test_undo_timeline.py | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 747789b..ba6e743 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -130,7 +130,6 @@ class TrackElementAction(UndoableAction):
UndoableAction.__init__(self)
self.clip = clip
self.track_element = track_element
- self.asset = track_element.get_asset()
self.track_element_props = []
for prop in self.track_element.list_children_properties():
if not prop.flags & GObject.PARAM_WRITABLE or \
@@ -142,13 +141,12 @@ class TrackElementAction(UndoableAction):
self.track_element_props.append((prop_name, value))
def add(self):
- self.track_element = self.clip.add_asset(self.asset)
+ assert self.clip.add(self.track_element)
for prop_name, prop_value in self.track_element_props:
self.track_element.set_child_property(prop_name, prop_value)
def remove(self):
self.clip.remove(self.track_element)
- self.track_element = None
class EffectAddedAction(TrackElementAction):
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 57229b8..91e41c2 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -583,7 +583,7 @@ class TestTimelineElementObserver(BaseTestUndoTimeline):
self.action_log.redo()
self.assertEqual(source.get_child_property("text")[1], "pigs fly!")
- def testChangeEffectProperty(self):
+ def test_add_effect_change_property(self):
stacks = []
self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb, stacks)
@@ -607,17 +607,33 @@ class TestTimelineElementObserver(BaseTestUndoTimeline):
with self.action_log.started("change child property"):
effect1.set_child_property("scratch-lines", 0)
-
self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)
+
+ # Undo effect property change.
self.action_log.undo()
self.assertEqual(effect1.get_child_property("scratch-lines")[1], 7)
+
+ # Redo effect property change.
self.action_log.redo()
self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)
+
+ # Undo effect property change.
self.action_log.undo()
self.assertTrue(effect1 in clip1.get_children(True))
+
+ # Undo effect add.
self.action_log.undo()
self.assertFalse(effect1 in clip1.get_children(True))
+ # Redo effect add.
+ self.action_log.redo()
+ self.assertTrue(effect1 in clip1.get_children(True))
+ self.assertEqual(effect1.get_child_property("scratch-lines")[1], 7)
+
+ # Redo effect property change.
+ self.action_log.redo()
+ self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)
+
class TestGObjectObserver(BaseTestUndoTimeline):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]