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

View File

@@ -714,7 +714,8 @@ class VIEW3D_MT_object_clear(bpy.types.Menu):
class VIEW3D_MT_object_specials(bpy.types.Menu):
bl_label = "Specials"
def poll(self, context):
@staticmethod
def poll(context):
# add more special types
return context.object
@@ -1939,7 +1940,8 @@ class VIEW3D_PT_view3d_properties(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "View"
def poll(self, context):
@staticmethod
def poll(context):
view = context.space_data
return (view)
@@ -1975,7 +1977,8 @@ class VIEW3D_PT_view3d_name(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Item"
def poll(self, context):
@staticmethod
def poll(context):
return (context.space_data and context.active_object)
def draw(self, context):
@@ -2000,7 +2003,8 @@ class VIEW3D_PT_view3d_display(bpy.types.Panel):
bl_label = "Display"
bl_default_closed = True
def poll(self, context):
@staticmethod
def poll(context):
view = context.space_data
return (view)
@@ -2067,7 +2071,8 @@ class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Mesh Display"
def poll(self, context):
@staticmethod
def poll(context):
# The active object check is needed because of localmode
return (context.active_object and (context.mode == 'EDIT_MESH'))
@@ -2103,7 +2108,8 @@ class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Curve Display"
def poll(self, context):
@staticmethod
def poll(context):
editmesh = context.mode == 'EDIT_CURVE'
return (editmesh)
@@ -2125,7 +2131,8 @@ class VIEW3D_PT_background_image(bpy.types.Panel):
bl_label = "Background Images"
bl_default_closed = True
def poll(self, context):
@staticmethod
def poll(context):
view = context.space_data
# bg = context.space_data.background_image
return (view)
@@ -2174,7 +2181,8 @@ class VIEW3D_PT_transform_orientations(bpy.types.Panel):
bl_label = "Transform Orientations"
bl_default_closed = True
def poll(self, context):
@staticmethod
def poll(context):
view = context.space_data
return (view)
@@ -2201,7 +2209,8 @@ class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
bl_label = "Skeleton Sketching"
bl_default_closed = True
def poll(self, context):
@staticmethod
def poll(context):
scene = context.space_data
ob = context.active_object
return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
@@ -2257,7 +2266,8 @@ class VIEW3D_PT_context_properties(bpy.types.Panel):
return ""
def poll(self, context):
@staticmethod
def poll(context):
member = self._active_context_member(context)
if member:
context_member = getattr(context, member)