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

@@ -29,15 +29,16 @@ class WorldButtonsPanel():
bl_context = "world"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
def poll(self, context):
rd = context.scene.render
return (context.world) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@staticmethod
def poll(context):
rd = context.scene.render
return (context.world) and (not rd.use_game_engine) and (rd.engine in __class__.COMPAT_ENGINES)
def draw(self, context):
self.layout.template_preview(context.world)
@@ -47,9 +48,10 @@ class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel):
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@staticmethod
def poll(context):
rd = context.scene.render
return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
return (not rd.use_game_engine) and (rd.engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -205,7 +207,8 @@ class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Indirect Lighting"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@staticmethod
def poll(context):
light = context.world.lighting
return light.gather_method == 'APPROXIMATE'