[pitivi] undo: Get rid of the undone_actions field



commit 457629e5cbcda40ef846d703ed0624866244be6b
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Dec 25 22:21:31 2016 +0100

    undo: Get rid of the undone_actions field
    
    The undone_actions field is not needed, it has no reason to exist.
    
    The done_actions field is enough. When undoing the stack, it's iterated
    from end to start and when redoing the stack, it's iterated from start
    to end.
    
    Differential Revision: https://phabricator.freedesktop.org/D1586

 pitivi/undo/undo.py |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/undo/undo.py b/pitivi/undo/undo.py
index 5483154..35de307 100644
--- a/pitivi/undo/undo.py
+++ b/pitivi/undo/undo.py
@@ -118,13 +118,20 @@ class FinalizingAction:
 
 
 class UndoableActionStack(UndoableAction):
-    """A stack of UndoableAction objects."""
+    """A stack of UndoableAction objects.
+
+    Attributes:
+        action_group_name (str): The name of the operation.
+        done_actions (List[UndoableAction]): The UndoableActions pushed in
+            the stack.
+        finalizing_action (FinalizingAction): The action to be performed
+            at the end of undoing or redoing the stacked actions.
+    """
 
     def __init__(self, action_group_name, finalizing_action=None):
         UndoableAction.__init__(self)
         self.action_group_name = action_group_name
         self.done_actions = []
-        self.undone_actions = []
         self.finalizing_action = finalizing_action
 
     def __repr__(self):
@@ -139,20 +146,17 @@ class UndoableActionStack(UndoableAction):
                     return
         self.done_actions.append(action)
 
-    def _runAction(self, action_list, method_name):
-        for action in action_list[::-1]:
+    def _run_action(self, actions, method_name):
+        for action in actions:
             method = getattr(action, method_name)
             method()
+        self.finish_operation()
 
     def do(self):
-        self._runAction(self.undone_actions, "do")
-        self.done_actions = self.undone_actions[::-1]
-        self.finish_operation()
+        self._run_action(self.done_actions, "do")
 
     def undo(self):
-        self._runAction(self.done_actions, "undo")
-        self.undone_actions = self.done_actions[::-1]
-        self.finish_operation()
+        self._run_action(self.done_actions[::-1], "undo")
 
     def finish_operation(self):
         if not self.finalizing_action:


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