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:
2010-08-05 16:05:30 +00:00
parent 5d18274cac
commit 163f6055d2
54 changed files with 845 additions and 368 deletions

View File

@@ -36,14 +36,16 @@ class DataButtonsPanel():
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
engine = context.scene.render.engine
return context.lamp and (engine in self.COMPAT_ENGINES)
class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.lamp and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
self.layout.template_preview(context.lamp)
@@ -52,6 +54,11 @@ class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.lamp and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -79,11 +86,21 @@ class DATA_PT_custom_props_lamp(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.lamp and (engine in __class__.COMPAT_ENGINES)
class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel):
bl_label = "Lamp"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.lamp and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -131,10 +148,11 @@ class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel):
bl_label = "Sky & Atmosphere"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@staticmethod
def poll(context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type == 'SUN') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type == 'SUN') and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -204,10 +222,11 @@ class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
bl_label = "Shadow"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@staticmethod
def poll(context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -329,10 +348,11 @@ class DATA_PT_area(DataButtonsPanel, bpy.types.Panel):
bl_label = "Area Shape"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@staticmethod
def poll(context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type == 'AREA') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type == 'AREA') and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -356,10 +376,11 @@ class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel):
bl_label = "Spot Shape"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@staticmethod
def poll(context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type == 'SPOT') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type == 'SPOT') and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -393,11 +414,12 @@ class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel):
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@staticmethod
def poll(context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
lamp = context.lamp