[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20404] branches/blender2.5/blender/ release/ui/buttons_texture.py: texture buttons raised py errors when there were no textures on an object

Campbell Barton ideasman42 at gmail.com
Mon May 25 16:58:10 CEST 2009


Revision: 20404
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20404
Author:   campbellbarton
Date:     2009-05-25 16:58:10 +0200 (Mon, 25 May 2009)

Log Message:
-----------
texture buttons raised py errors when there were no textures on an object

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_texture.py

Modified: branches/blender2.5/blender/release/ui/buttons_texture.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_texture.py	2009-05-25 13:48:44 UTC (rev 20403)
+++ branches/blender2.5/blender/release/ui/buttons_texture.py	2009-05-25 14:58:10 UTC (rev 20404)
@@ -7,8 +7,8 @@
 	__context__ = "texture"
 	
 	def poll(self, context):
-		ob = context.active_object
-		return (ob and ob.active_material.active_texture.texture)
+		try:	return (context.active_object.active_material.active_texture.texture != None)
+		except:return False
 
 class TEXTURE_PT_texture(TextureButtonsPanel):
 	__idname__= "TEXTURE_PT_texture"
@@ -25,8 +25,8 @@
 	__label__ = "Clouds"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "CLOUDS")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'CLOUDS')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -47,8 +47,8 @@
 	__label__ = "Wood"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "WOOD")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'WOOD')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -70,8 +70,8 @@
 	__label__ = "Marble"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "MARBLE")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'MARBLE')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -94,8 +94,8 @@
 	__label__ = "Magic"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "MAGIC")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'MAGIC')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -110,8 +110,8 @@
 	__label__ = "Blend"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "BLEND")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'BLEND')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -125,8 +125,8 @@
 	__label__ = "Stucci"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "STUCCI")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'STUCCI')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -146,8 +146,8 @@
 	__label__ = "Image/Movie"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "IMAGE")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'IMAGE')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -173,8 +173,8 @@
 	__label__ = "Mapping"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "IMAGE")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'IMAGE')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -216,8 +216,8 @@
 	__label__ = "Plugin"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "PLUGIN")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'PLUGIN')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -230,8 +230,8 @@
 	__label__ = "Environment Map"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "ENVIRONMENT_MAP")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'ENVIRONMENT_MAP')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -244,8 +244,8 @@
 	__label__ = "Musgrave"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "MUSGRAVE")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'MUSGRAVE')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
@@ -277,9 +277,10 @@
 	__label__ = "Voronoi"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "VORONOI")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'VORONOI')
+		except:return False
 
+
 	def draw(self, context):
 		layout = self.layout
 		tex = context.active_object.active_material.active_texture.texture
@@ -306,13 +307,13 @@
 	__label__ = "Distorted Noise"
 	
 	def poll(self, context):
-		tex = context.active_object.active_material.active_texture.texture
-		return (tex and tex.type == "DISTORTED_NOISE")	
+		try:	return (context.active_object.active_material.active_texture.texture.type == 'DISTORTED_NOISE')
+		except:return False
 
 	def draw(self, context):
 		layout = self.layout
 		tex = context.active_object.active_material.active_texture.texture
- 
+
 		layout.itemR(tex, "noise_distortion")
 		layout.itemR(tex, "noise_basis", text="Basis")
 		
@@ -333,4 +334,4 @@
 bpy.types.register(TEXTURE_PT_envmap)
 bpy.types.register(TEXTURE_PT_musgrave)
 bpy.types.register(TEXTURE_PT_voronoi)
-bpy.types.register(TEXTURE_PT_distortednoise)
\ No newline at end of file
+bpy.types.register(TEXTURE_PT_distortednoise)





More information about the Bf-blender-cvs mailing list