[pitivi] undo: Ignore empty transactions when committing
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] undo: Ignore empty transactions when committing
- Date: Mon, 23 May 2016 08:38:53 +0000 (UTC)
commit 0de65fd03f2cfc95e0e6a0688bca0410450020fb
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Tue May 17 07:23:50 2016 +0200
undo: Ignore empty transactions when committing
There are cases when no action is pushed in a transaction. We could make
sure this does not happen but it's easier to ignore them.
Differential Revision: https://phabricator.freedesktop.org/D995
pitivi/undo/undo.py | 5 ++++-
tests/test_undo.py | 18 ++++++++++++------
2 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/undo/undo.py b/pitivi/undo/undo.py
index 8436ce7..e60d987 100644
--- a/pitivi/undo/undo.py
+++ b/pitivi/undo/undo.py
@@ -202,10 +202,13 @@ class UndoableActionLog(GObject.Object, Loggable):
self.debug("Ignore commit because running")
return
- self.debug("Committing")
+ self.debug("Committing %s", action_group_name)
stack = self._get_last_stack(pop=True)
if action_group_name != stack.action_group_name:
raise UndoWrongStateError("Unexpected commit", action_group_name, stack, self.stacks)
+ if not stack.done_actions:
+ self.debug("Ignore empty stack %s", stack.action_group_name)
+ return
if not self.stacks:
self.undo_stacks.append(stack)
else:
diff --git a/tests/test_undo.py b/tests/test_undo.py
index ecd7192..33ba6ee 100644
--- a/tests/test_undo.py
+++ b/tests/test_undo.py
@@ -147,9 +147,12 @@ class TestUndoableActionLog(TestCase):
self.assertTrue(self.log.is_in_transaction())
self.assertEqual(self.log.undo_stacks, [])
+ self.log.push(mock.Mock())
self.log.commit("meh")
- self.assertEqual(len(self.signals), 2)
- name, (stack,) = self.signals[1]
+ self.assertEqual(len(self.signals), 3)
+ name, (stack, action) = self.signals[1]
+ self.assertEqual(name, "push")
+ name, (stack,) = self.signals[2]
self.assertEqual(name, "commit")
self.assertFalse(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 1)
@@ -180,9 +183,12 @@ class TestUndoableActionLog(TestCase):
self.assertTrue(self.log.is_in_transaction())
self.assertEqual(self.log.undo_stacks, [])
+ self.log.push(mock.Mock())
self.log.commit("nested")
- self.assertEqual(len(self.signals), 3)
- name, (stack,) = self.signals[2]
+ self.assertEqual(len(self.signals), 4)
+ name, (stack, action) = self.signals[2]
+ self.assertEqual(name, "push")
+ name, (stack,) = self.signals[3]
self.assertEqual(name, "commit")
self.assertTrue(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 0)
@@ -190,8 +196,8 @@ class TestUndoableActionLog(TestCase):
self.assertEqual(self.log.undo_stacks, [])
self.log.commit("meh")
- self.assertEqual(len(self.signals), 4)
- name, (stack,) = self.signals[3]
+ self.assertEqual(len(self.signals), 5)
+ name, (stack,) = self.signals[4]
self.assertEqual(name, "commit")
self.assertFalse(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]