bugfix [#23182] Using self.report() inside poll() gives crash
poll() function is now a static method in python, this is more correct, matching C where the operator is not created to run poll. def poll(self, context): ... is now... @staticmethod def poll(context): ... Pythons way of doing static methods is a bit odd but cant be helped :| This does make subclassing poll functions with COMPAT_ENGINES break, so had to modify quite a few scripts for this.
This commit is contained in:
@@ -70,18 +70,16 @@ class TextureButtonsPanel():
|
||||
bl_region_type = 'WINDOW'
|
||||
bl_context = "texture"
|
||||
|
||||
def poll(self, context):
|
||||
tex = context.texture
|
||||
if not tex:
|
||||
return False
|
||||
engine = context.scene.render.engine
|
||||
return (tex.type != 'NONE' or tex.use_nodes) and (engine in self.COMPAT_ENGINES)
|
||||
|
||||
|
||||
class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Preview"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -100,12 +98,13 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
|
||||
bl_show_header = False
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
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))
|
||||
and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -170,9 +169,10 @@ class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Pane
|
||||
_context_path = "texture"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context): # use alternate poll since NONE texture type is ok
|
||||
@staticmethod
|
||||
def poll(context): # use alternate poll since NONE texture type is ok
|
||||
engine = context.scene.render.engine
|
||||
return context.texture and (engine in self.COMPAT_ENGINES)
|
||||
return context.texture and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
|
||||
class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
|
||||
@@ -180,6 +180,11 @@ class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
|
||||
bl_default_closed = True
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -212,19 +217,21 @@ class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
|
||||
class TextureSlotPanel(TextureButtonsPanel):
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
if not hasattr(context, "texture_slot"):
|
||||
return False
|
||||
|
||||
engine = context.scene.render.engine
|
||||
return TextureButtonsPanel.poll(self, context) and (engine in self.COMPAT_ENGINES)
|
||||
return TextureButtonsPanel.poll(self, context) and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
|
||||
class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel):
|
||||
bl_label = "Mapping"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
idblock = context_tex_datablock(context)
|
||||
if type(idblock) == bpy.types.Brush and not context.sculpt_object:
|
||||
return False
|
||||
@@ -233,7 +240,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel):
|
||||
return False
|
||||
|
||||
engine = context.scene.render.engine
|
||||
return (engine in self.COMPAT_ENGINES)
|
||||
return (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -321,7 +328,8 @@ class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
|
||||
bl_label = "Influence"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
idblock = context_tex_datablock(context)
|
||||
if type(idblock) == bpy.types.Brush:
|
||||
return False
|
||||
@@ -330,7 +338,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
|
||||
return False
|
||||
|
||||
engine = context.scene.render.engine
|
||||
return (engine in self.COMPAT_ENGINES)
|
||||
return (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
@@ -443,12 +451,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
|
||||
|
||||
|
||||
class TextureTypePanel(TextureButtonsPanel):
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return ((tex and tex.type == self.tex_type and not tex.use_nodes) and (engine in self.COMPAT_ENGINES))
|
||||
pass
|
||||
|
||||
|
||||
class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel):
|
||||
@@ -456,6 +459,12 @@ class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'CLOUDS'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -486,6 +495,12 @@ class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'WOOD'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -523,6 +538,12 @@ class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'MARBLE'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -555,6 +576,12 @@ class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'MAGIC'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -576,6 +603,12 @@ class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'BLEND'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -598,6 +631,12 @@ class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'STUCCI'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -627,6 +666,12 @@ class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'IMAGE'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -654,6 +699,12 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'IMAGE'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -695,6 +746,12 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'IMAGE'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -753,6 +810,12 @@ class TEXTURE_PT_plugin(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'PLUGIN'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -766,6 +829,12 @@ class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'ENVIRONMENT_MAP'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -808,6 +877,12 @@ class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'ENVIRONMENT_MAP'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -821,6 +896,12 @@ class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'MUSGRAVE'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -869,6 +950,12 @@ class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'VORONOI'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -913,6 +1000,12 @@ class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel):
|
||||
tex_type = 'DISTORTED_NOISE'
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -941,10 +1034,11 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Voxel Data"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return (tex and tex.type == 'VOXEL_DATA' and (engine in self.COMPAT_ENGINES))
|
||||
return tex and (tex.type == 'VOXEL_DATA' and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -979,10 +1073,11 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Point Density"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return (tex and tex.type == 'POINT_DENSITY' and (engine in self.COMPAT_ENGINES))
|
||||
return tex and (tex.type == 'POINT_DENSITY' and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -1039,10 +1134,11 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Turbulence"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
tex = context.texture
|
||||
engine = context.scene.render.engine
|
||||
return (tex and tex.type == 'POINT_DENSITY' and (engine in self.COMPAT_ENGINES))
|
||||
return tex and (tex.type == 'POINT_DENSITY' and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
|
Reference in New Issue
Block a user