[pitivi/gtktimeline] layer: Cleanly release when a clip is moved to another layer



commit 93f649067ecce98de52e17a4d2c9f1a8d084c58c
Author: Thibault Saunier <tsaunier gnome org>
Date:   Fri Jun 5 19:12:10 2015 +0200

    layer: Cleanly release when a clip is moved to another layer

 pitivi/timeline/elements.py |   13 ++++++++++---
 pitivi/timeline/layer.py    |    1 +
 2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 108b1b5..7d56943 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -680,6 +680,10 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
         self.connect("button-release-event", self._clickedCb)
         self.connect("event", self._eventCb)
 
+    def release(self):
+        for child in self.bClip.get_children(True):
+            self.__disconnectFromChild(child)
+
     def __showHandles(self):
         for handle in self.handles:
             handle.show()
@@ -719,6 +723,11 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
         if bLayer:
             self.layer = bLayer.ui
 
+    def __disconnectFromChild(self, child):
+        if child.ui and hasattr(child.ui, "__clip_curve_enter_id") and child.ui.__clip_curve_enter_id:
+            child.ui.disconnect_by_func(child.ui.__clip_curve_enter_id)
+            child.ui.disconnect_by_func(child.ui.__clip_curve_leave_id)
+
     def __connectToChild(self, child):
         if child.ui:
             child.ui.connect("curve-enter", self.__curveEnterCb)
@@ -744,9 +753,7 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
 
     def _childRemovedCb(self, clip, child):
         self.__force_position_update = True
-        if child.ui:
-            child.ui.disconnect_by_func(self.__curveEnterCb)
-            child.ui.disconnect_by_func(self.__curveLeaveCb)
+        self.__disconnectFromChild(child)
         self._childRemoved(clip, child)
 
     def _connectGES(self):
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index 3d1a0d8..f6698d1 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -519,6 +519,7 @@ class Layer(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
         bClip = clip.bClip
         bClip.ui.layer = None
         if self.timeline.draggingElement is None:
+            bClip.ui.release()
             bClip.ui = None
 
         bClip.disconnect_by_func(self._childAddedCb)


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