don't crash if boolean source returns None
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 7 Oct 2007 09:22:47 +0000 (09:22 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 7 Oct 2007 09:22:47 +0000 (09:22 +0000)
lib/python/Components/Converter/ConditionalShowHide.py

index 8d9baf7..2d4b99a 100644 (file)
@@ -5,10 +5,18 @@ class ConditionalShowHide(Converter, object):
                Converter.__init__(self, type)
                self.invert = type == "Invert"
 
+       def calcVisibility(self):
+               b = self.source.boolean
+               if b is None:
+                       return True
+               b ^= self.invert
+               return b
+
        def changed(self, what):
+               vis = self.calcVisibility()
                for x in self.downstream_elements:
-                       x.visible = self.source.boolean ^ self.invert
+                       x.visible = vis
 
        def connectDownstream(self, downstream):
                Converter.connectDownstream(self, downstream)
-               downstream.visible = self.source.boolean ^ self.invert
+               downstream.visible = self.calcVisibility()