[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28348] trunk/blender/release/scripts/ui/ properties_texture.py: avoid try/except with in texture UI

Campbell Barton ideasman42 at gmail.com
Thu Apr 22 18:22:47 CEST 2010


Revision: 28348
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28348
Author:   campbellbarton
Date:     2010-04-22 18:22:47 +0200 (Thu, 22 Apr 2010)

Log Message:
-----------
avoid try/except with in texture UI

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_texture.py

Modified: trunk/blender/release/scripts/ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_texture.py	2010-04-22 15:59:27 UTC (rev 28347)
+++ trunk/blender/release/scripts/ui/properties_texture.py	2010-04-22 16:22:47 UTC (rev 28348)
@@ -83,10 +83,7 @@
         layout = self.layout
 
         tex = context.texture
-        try:
-            slot = context.texture_slot
-        except:
-            slot = None
+        slot = getattr(context, "texture_slot", None)
         idblock = context_tex_datablock(context)
 
         if idblock:
@@ -102,8 +99,8 @@
 
     def poll(self, context):
         engine = context.scene.render.engine
-        try: getattr(context, "texture_slot")
-        except: return False
+        if not hasattr(context, "texture_slot"):
+            return False
         return ((context.material or context.world or context.lamp or context.brush or context.texture) 
             and (engine in self.COMPAT_ENGINES))
 
@@ -212,8 +209,8 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
-        try: getattr(context, "texture_slot")
-        except: return False
+        if not hasattr(context, "texture_slot"):
+            return False
         
         engine = context.scene.render.engine
         return TextureButtonsPanel.poll(self, context) and (engine in self.COMPAT_ENGINES)
@@ -227,11 +224,12 @@
         idblock = context_tex_datablock(context)
         if type(idblock) == bpy.types.Brush and not context.sculpt_object:
             return False
-        try: getattr(context, "texture_slot")
-        except: return False
+
+        if not getattr(context, "texture_slot", None):
+            return False
         
         engine = context.scene.render.engine
-        return context.texture_slot and (engine in self.COMPAT_ENGINES)
+        return (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -324,11 +322,12 @@
         idblock = context_tex_datablock(context)
         if type(idblock) == bpy.types.Brush:
             return False
-        try: getattr(context, "texture_slot")
-        except: return False
 
+        if getattr(context, "texture_slot", None):
+            return False
+
         engine = context.scene.render.engine
-        return context.texture_slot and (engine in self.COMPAT_ENGINES)
+        return (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
 





More information about the Bf-blender-cvs mailing list