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:
@@ -54,16 +54,17 @@ class DataButtonsPanel():
|
||||
bl_region_type = 'WINDOW'
|
||||
bl_context = "data"
|
||||
|
||||
def poll(self, context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in self.COMPAT_ENGINES)
|
||||
|
||||
|
||||
class DATA_PT_context_mesh(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = ""
|
||||
bl_show_header = False
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -91,11 +92,21 @@ class DATA_PT_custom_props_mesh(DataButtonsPanel, PropertyPanel, bpy.types.Panel
|
||||
_context_path = "object.data"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
|
||||
class DATA_PT_normals(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Normals"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -121,6 +132,11 @@ class DATA_PT_settings(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Settings"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -133,9 +149,11 @@ class DATA_PT_vertex_groups(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Vertex Groups"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return (context.object and context.object.type in ('MESH', 'LATTICE') and (engine in self.COMPAT_ENGINES))
|
||||
obj = context.object
|
||||
return (obj and obj.type in ('MESH', 'LATTICE') and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -180,9 +198,11 @@ class DATA_PT_shape_keys(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Shape Keys"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return (context.object and context.object.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in self.COMPAT_ENGINES))
|
||||
obj = context.object
|
||||
return (obj and obj.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in __class__.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -278,6 +298,11 @@ class DATA_PT_uv_texture(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "UV Texture"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -301,7 +326,8 @@ class DATA_PT_texface(DataButtonsPanel):
|
||||
bl_label = "Texture Face"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
def poll(self, context):
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
ob = context.active_object
|
||||
rd = context.scene.render
|
||||
|
||||
@@ -348,6 +374,11 @@ class DATA_PT_vertex_colors(DataButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Vertex Colors"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
|
||||
@staticmethod
|
||||
def poll(context):
|
||||
engine = context.scene.render.engine
|
||||
return context.mesh and (engine in __class__.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
|
||||
Reference in New Issue
Block a user