[pitivi] timeline: Raise a proper exception if no element is found



commit b278807909cd3001a2bfe01b87fa1e1fcfb63c75
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue Dec 17 17:16:59 2013 +0100

    timeline: Raise a proper exception if no element is found

 pitivi/timeline/timeline.py |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index f348145..05fb855 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -32,7 +32,7 @@ from gi.repository import Gst, GES, GObject, Clutter, Gtk, GLib, Gdk
 
 from pitivi.autoaligner import AlignmentProgressDialog, AutoAligner
 from pitivi.check import at_least_version
-from pitivi.utils.timeline import Zoomable, Selection, SELECT
+from pitivi.utils.timeline import Zoomable, Selection, SELECT, TimelineError
 from pitivi.settings import GlobalSettings
 from pitivi.dialogs.prefs import PreferencesDialog
 from pitivi.utils.loggable import Loggable
@@ -476,15 +476,20 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
         bElement.disconnect_by_func(self._elementInPointChangedCb)
         bElement.disconnect_by_func(self._elementPriorityChangedCb)
 
-        for element in self.elements:
-            if element.bElement == bElement:
-                break
-
+        element = self._getElement(bElement)
+        if not element:
+            raise TimelineError("Missing element for: " + bElement)
         element.cleanup()
         self.elements.remove(element)
         self.remove_child(element)
         self.selection.setSelection(set([]), SELECT)
 
+    def _getElement(self, bElement):
+        for element in self.elements:
+            if element.bElement == bElement:
+                return element
+        return None
+
     def _setElementX(self, element, ease=True):
         if ease:
             element.save_easing_state()


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