[pitivi] undo: Fix effect priority changed when re-added.
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] undo: Fix effect priority changed when re-added.
- Date: Sat, 10 Nov 2018 20:31:30 +0000 (UTC)
commit d614b6475d33a6879e140e6af5312b875efc044a
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Sep 23 23:22:10 2018 +0200
undo: Fix effect priority changed when re-added.
Fixes #2246
pitivi/undo/timeline.py | 4 +++
tests/test_undo_timeline.py | 80 ++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 76 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 62cb2d08..4b79004c 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -212,7 +212,11 @@ class TrackElementRemoved(TrackElementAction):
self.remove()
def undo(self):
+ # Set the priority it had when it was last removed from self.clip,
+ # because re-adding it can change it, for example if it's an effect.
+ priority = self.track_element.props.priority
self.add()
+ self.track_element.props.priority = priority
def asScenarioAction(self):
st = Gst.Structure.new_empty("container-remove-child")
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 3e9733cd..4c6d6757 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -735,6 +735,19 @@ class TestControlSourceObserver(BaseTestUndoTimeline):
class TestTrackElementObserver(BaseTestUndoTimeline):
+ def assert_effects(self, clip, *effects):
+ # Make sure there are no other effects.
+ actual_effects = set()
+ for track_element in clip.get_children(recursive=True):
+ if isinstance(track_element, GES.BaseEffect):
+ actual_effects.add(track_element)
+ self.assertEqual(actual_effects, set(effects))
+
+ # Make sure their order is correct.
+ indexes = [clip.get_top_effect_index(effect)
+ for effect in effects]
+ self.assertEqual(indexes, list(range(len(effects))))
+
def test_effects_index(self):
stacks = []
self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb, stacks)
@@ -746,24 +759,75 @@ class TestTrackElementObserver(BaseTestUndoTimeline):
effect2 = GES.Effect.new("edgetv")
clip1.add(effect1)
clip1.add(effect2)
- self.assertEqual(clip1.get_top_effect_index(effect1), 0)
- self.assertEqual(clip1.get_top_effect_index(effect2), 1)
+ self.assert_effects(clip1, effect1, effect2)
with self.action_log.started("move effect"):
assert clip1.set_top_effect_index(effect2, 0)
self.assertEqual(len(stacks), 1)
+ self.assert_effects(clip1, effect2, effect1)
+
+ self.action_log.undo()
+ self.assert_effects(clip1, effect1, effect2)
+
+ self.action_log.redo()
+ self.assert_effects(clip1, effect2, effect1)
- self.assertEqual(clip1.get_top_effect_index(effect1), 1)
- self.assertEqual(clip1.get_top_effect_index(effect2), 0)
+ def test_effects_index_with_removal(self):
+ stacks = []
+ self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb, stacks)
+ clip1 = GES.TitleClip()
+ self.layer.add_clip(clip1)
+
+ effect1 = GES.Effect.new("agingtv")
+ effect2 = GES.Effect.new("dicetv")
+ effect3 = GES.Effect.new("edgetv")
+ with self.action_log.started("Add effect1"):
+ clip1.add(effect1)
+ with self.action_log.started("Add effect2"):
+ clip1.add(effect2)
+ with self.action_log.started("Add effect3"):
+ clip1.add(effect3)
+ self.assert_effects(clip1, effect1, effect2, effect3)
self.action_log.undo()
- self.assertEqual(clip1.get_top_effect_index(effect1), 0)
- self.assertEqual(clip1.get_top_effect_index(effect2), 1)
+ self.assert_effects(clip1, effect1, effect2)
+ self.action_log.redo()
+ self.assert_effects(clip1, effect1, effect2, effect3)
+
+ with self.action_log.started("Remove effect"):
+ assert clip1.remove(effect2)
+ self.assertEqual(len(stacks), 4)
+ self.assert_effects(clip1, effect1, effect3)
+ self.action_log.undo()
+ self.assert_effects(clip1, effect1, effect2, effect3)
+
+ self.action_log.redo()
+ self.assert_effects(clip1, effect1, effect3)
+
+ self.action_log.undo()
+ self.assert_effects(clip1, effect1, effect2, effect3)
+ self.action_log.undo()
+ self.assert_effects(clip1, effect1, effect2)
+ self.action_log.undo()
+ self.assert_effects(clip1, effect1)
+ self.action_log.undo()
+ self.assert_effects(clip1)
+
+ self.action_log.redo()
+ self.assert_effects(clip1, effect1)
+ self.action_log.redo()
+ self.assert_effects(clip1, effect1, effect2)
+ self.action_log.redo()
+ self.assert_effects(clip1, effect1, effect2, effect3)
+ self.action_log.redo()
+ self.assert_effects(clip1, effect1, effect3)
+
+ self.action_log.undo()
+ self.assert_effects(clip1, effect1, effect2, effect3)
self.action_log.redo()
- self.assertEqual(clip1.get_top_effect_index(effect1), 1)
- self.assertEqual(clip1.get_top_effect_index(effect2), 0)
+ self.assert_effects(clip1, effect1, effect3)
class TestTimelineElementObserver(BaseTestUndoTimeline):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]