[pitivi/wip-speed-control: 2/8] clipproperties: Fix title clip selection generating undoable operations




commit ede2839f3a38ccb87c92256bb0ca973ad90a51b5
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Jan 24 20:43:23 2021 +0100

    clipproperties: Fix title clip selection generating undoable operations
    
    When the title clip was being selected, two new operations were added to
    the undo stack, potentially erasing the redo stack:
    - text being set to "",
    - text being restored.

 pitivi/clip_properties/title.py | 11 ++++++-----
 tests/test_clipproperties.py    | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/clip_properties/title.py b/pitivi/clip_properties/title.py
index 8eecc10d3..a37b7472b 100644
--- a/pitivi/clip_properties/title.py
+++ b/pitivi/clip_properties/title.py
@@ -167,7 +167,7 @@ class TitleProperties(Gtk.Expander, Loggable):
         color = argb_to_gdk_rgba(source.get_child_property("foreground-color")[1])
         self.background_color_button.set_rgba(color)
 
-    def _text_changed_cb(self, unused_updated_obj):
+    def _text_changed_cb(self, unused_text_buffer):
         if not self.source:
             # Nothing to update.
             return
@@ -212,13 +212,14 @@ class TitleProperties(Gtk.Expander, Loggable):
             self.source.disconnect(self._children_props_handler)
             self._children_props_handler = None
 
-        self.source = source
-
         if source:
             assert isinstance(source, (GES.TextOverlay, GES.TitleSource))
             self._update_from_source(source)
-            self._children_props_handler = self.source.connect("deep-notify",
-                                                               self._source_deep_notify_cb)
+            self._children_props_handler = source.connect("deep-notify",
+                                                          self._source_deep_notify_cb)
+
+        self.source = source
+
         self.set_visible(bool(self.source))
 
     def _source_deep_notify_cb(self, source, unused_gstelement, pspec):
diff --git a/tests/test_clipproperties.py b/tests/test_clipproperties.py
index 24744572c..9f376f702 100644
--- a/tests/test_clipproperties.py
+++ b/tests/test_clipproperties.py
@@ -349,3 +349,19 @@ class ClipPropertiesTest(common.TestCase):
 
         self.assertEqual(source.get_child_property("posx").value, -width)
         self.assertEqual(source.get_child_property("posy").value, -height)
+
+    @common.setup_timeline
+    @common.setup_clipproperties
+    def test_selection_does_nothing(self):
+        """Checks de/selection do not create undoable operations."""
+        self.project.pipeline.get_position = mock.Mock(return_value=0)
+        self.clipproperties.create_title_clip_cb(None)
+        self.assertEqual(len(self.action_log.undo_stacks), 1)
+        clips = self.layer.get_clips()
+        self.assertEqual(len(clips), 1, clips)
+
+        self.timeline_container.timeline.selection.unselect(clips)
+        self.assertEqual(len(self.action_log.undo_stacks), 1)
+
+        self.timeline_container.timeline.selection.select(clips)
+        self.assertEqual(len(self.action_log.undo_stacks), 1)


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