[pitivi] titleeditor: Prevent choking on None text properties



commit 58f9eaac4926d9ab9f2117a8c07d3d7ac98e1cd0
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Mon Sep 10 16:34:45 2012 -0400

    titleeditor: Prevent choking on None text properties

 pitivi/titleeditor.py |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index 2150a2d..5c7e1cd 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -709,10 +709,15 @@ class TitleEditor(Loggable):
 
     def _updateFromSource(self):
         if self.source is not None:
-            self.log("Title text set to %s", self.source.get_text())
-
-            self.pangobuffer.set_text(self.source.get_text())
-            self.textbuffer.set_text(self.source.get_text())
+            source_text = self.source.get_text()
+            self.log("Title text set to %s", source_text)
+            if source_text is None:
+                # FIXME: sometimes we get a TrackTextOverlay/TrackTitleSource
+                # without a valid text property. This should not happen.
+                source_text = ""
+                self.warning('Source did not have a text property, setting it to "" to avoid pango choking up on None')
+            self.pangobuffer.set_text(source_text)
+            self.textbuffer.set_text(source_text)
             self.settings['xpos'].set_value(self.source.get_xpos())
             self.settings['ypos'].set_value(self.source.get_ypos())
             self.settings['valignment'].set_active_id(self.source.get_valignment().value_name)
@@ -786,6 +791,9 @@ class TitleEditor(Loggable):
         if source is None:
             self._deactivate()
         else:
+            assert isinstance(source, GES.TrackTextOverlay) or \
+                   isinstance(source, GES.TrackTitleSource) or \
+                   isinstance(source, GES.TimelineTitleSource)
             self._updateFromSource()
             self._activate()
 



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