From 163f6055d26383b7fa11df00da09ef63efb8cb6c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Aug 2010 16:05:30 +0000 Subject: 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. --- release/scripts/io/export_3ds.py | 3 +- release/scripts/io/export_fbx.py | 3 +- release/scripts/io/export_mdd.py | 3 +- release/scripts/io/export_ply.py | 3 +- release/scripts/io/import_shape_mdd.py | 3 +- release/scripts/io/netrender/operators.py | 42 ++++-- release/scripts/io/netrender/ui.py | 61 +++++--- release/scripts/op/fcurve_euler_filter.py | 3 +- release/scripts/op/mesh.py | 6 +- release/scripts/op/object.py | 18 ++- release/scripts/op/object_align.py | 3 +- release/scripts/op/sequencer.py | 9 +- release/scripts/op/uv.py | 3 +- release/scripts/op/uvcalc_follow_active.py | 3 +- release/scripts/op/uvcalc_smart_project.py | 3 +- release/scripts/templates/operator.py | 3 +- release/scripts/templates/operator_simple.py | 3 +- release/scripts/templates/operator_uv.py | 3 +- release/scripts/ui/properties_data_armature.py | 15 +- .../scripts/ui/properties_data_armature_rigify.py | 9 +- release/scripts/ui/properties_data_bone.py | 12 +- release/scripts/ui/properties_data_camera.py | 24 +++- release/scripts/ui/properties_data_curve.py | 21 ++- release/scripts/ui/properties_data_empty.py | 3 +- release/scripts/ui/properties_data_lamp.py | 48 +++++-- release/scripts/ui/properties_data_lattice.py | 3 +- release/scripts/ui/properties_data_mesh.py | 49 +++++-- release/scripts/ui/properties_data_metaball.py | 6 +- release/scripts/ui/properties_game.py | 72 +++++++--- release/scripts/ui/properties_material.py | 84 ++++++----- release/scripts/ui/properties_object.py | 6 +- release/scripts/ui/properties_object_constraint.py | 6 +- release/scripts/ui/properties_particle.py | 77 +++++++---- release/scripts/ui/properties_physics_cloth.py | 15 +- release/scripts/ui/properties_physics_field.py | 6 +- release/scripts/ui/properties_physics_fluid.py | 18 ++- release/scripts/ui/properties_physics_smoke.py | 18 ++- release/scripts/ui/properties_physics_softbody.py | 21 ++- release/scripts/ui/properties_render.py | 62 ++++++++- release/scripts/ui/properties_scene.py | 6 +- release/scripts/ui/properties_texture.py | 154 +++++++++++++++++---- release/scripts/ui/properties_world.py | 17 ++- release/scripts/ui/space_console.py | 3 +- release/scripts/ui/space_image.py | 36 +++-- release/scripts/ui/space_logic.py | 3 +- release/scripts/ui/space_sequencer.py | 24 ++-- release/scripts/ui/space_text.py | 3 +- release/scripts/ui/space_userpref.py | 21 ++- release/scripts/ui/space_userpref_keymap.py | 3 +- release/scripts/ui/space_view3d.py | 30 ++-- release/scripts/ui/space_view3d_toolbar.py | 59 ++++---- source/blender/makesrna/intern/rna_ui.c | 4 +- source/blender/makesrna/intern/rna_wm_api.c | 4 +- source/blender/python/intern/bpy_rna.c | 96 +++++++------ 54 files changed, 845 insertions(+), 368 deletions(-) diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index 22b842b2905..0b71ec93a99 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -1135,7 +1135,8 @@ class Export3DS(bpy.types.Operator): wm.add_fileselect(self) return {'RUNNING_MODAL'} - def poll(self, context): # Poll isnt working yet + @staticmethod + def poll(context): # Poll isnt working yet return context.active_object != None # Add to a menu diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 8d28500dba5..a7320884b5d 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -3361,7 +3361,8 @@ class ExportFBX(bpy.types.Operator): BATCH_FILE_PREFIX = StringProperty(name="Prefix", description="Prefix each file with this name", maxlen=1024, default="") - def poll(self, context): + @staticmethod + def poll(context): return context.active_object def execute(self, context): diff --git a/release/scripts/io/export_mdd.py b/release/scripts/io/export_mdd.py index 5cbda8a76b7..d7b5efe7497 100644 --- a/release/scripts/io/export_mdd.py +++ b/release/scripts/io/export_mdd.py @@ -165,7 +165,8 @@ class ExportMDD(bpy.types.Operator): frame_start = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1) frame_end = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250) - def poll(self, context): + @staticmethod + def poll(context): ob = context.active_object return (ob and ob.type == 'MESH') diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 03529c4023c..c92a0690de4 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -275,7 +275,8 @@ class ExportPLY(bpy.types.Operator): use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True) use_colors = BoolProperty(name="Vertex Colors", description="Exort the active vertex color layer", default=True) - def poll(self, context): + @staticmethod + def poll(context): return context.active_object != None def execute(self, context): diff --git a/release/scripts/io/import_shape_mdd.py b/release/scripts/io/import_shape_mdd.py index 16fed1798c4..3245decc806 100644 --- a/release/scripts/io/import_shape_mdd.py +++ b/release/scripts/io/import_shape_mdd.py @@ -120,7 +120,8 @@ class importMDD(bpy.types.Operator): #fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25) frame_start = IntProperty(name="Start Frame", description="Start frame for inserting animation", min=minframe, max=maxframe, default=0) - def poll(self, context): + @staticmethod + def poll(context): ob = context.active_object return (ob and ob.type == 'MESH') diff --git a/release/scripts/io/netrender/operators.py b/release/scripts/io/netrender/operators.py index 4530491dae1..35f356e0a65 100644 --- a/release/scripts/io/netrender/operators.py +++ b/release/scripts/io/netrender/operators.py @@ -31,7 +31,8 @@ class RENDER_OT_netslave_bake(bpy.types.Operator): bl_idname = "render.netslavebake" bl_label = "Bake all in file" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -88,7 +89,8 @@ class RENDER_OT_netclientanim(bpy.types.Operator): bl_idname = "render.netclientanim" bl_label = "Animation on network" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -114,7 +116,8 @@ class RENDER_OT_netclientrun(bpy.types.Operator): bl_idname = "render.netclientstart" bl_label = "Start Service" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -130,7 +133,8 @@ class RENDER_OT_netclientsend(bpy.types.Operator): bl_idname = "render.netclientsend" bl_label = "Send job" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -159,7 +163,8 @@ class RENDER_OT_netclientsendframe(bpy.types.Operator): bl_idname = "render.netclientsendframe" bl_label = "Send current frame job" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -188,7 +193,8 @@ class RENDER_OT_netclientstatus(bpy.types.Operator): bl_idname = "render.netclientstatus" bl_label = "Client Status" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -227,7 +233,8 @@ class RENDER_OT_netclientblacklistslave(bpy.types.Operator): bl_idname = "render.netclientblacklistslave" bl_label = "Client Blacklist Slave" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -256,7 +263,8 @@ class RENDER_OT_netclientwhitelistslave(bpy.types.Operator): bl_idname = "render.netclientwhitelistslave" bl_label = "Client Whitelist Slave" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -286,7 +294,8 @@ class RENDER_OT_netclientslaves(bpy.types.Operator): bl_idname = "render.netclientslaves" bl_label = "Client Slaves" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -330,7 +339,8 @@ class RENDER_OT_netclientcancel(bpy.types.Operator): bl_idname = "render.netclientcancel" bl_label = "Client Cancel" - def poll(self, context): + @staticmethod + def poll(context): netsettings = context.scene.network_render return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0 @@ -358,7 +368,8 @@ class RENDER_OT_netclientcancelall(bpy.types.Operator): bl_idname = "render.netclientcancelall" bl_label = "Client Cancel All" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -384,7 +395,8 @@ class netclientdownload(bpy.types.Operator): bl_idname = "render.netclientdownload" bl_label = "Client Download" - def poll(self, context): + @staticmethod + def poll(context): netsettings = context.scene.network_render return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0 @@ -428,7 +440,8 @@ class netclientscan(bpy.types.Operator): bl_idname = "render.netclientscan" bl_label = "Client Scan" - def poll(self, context): + @staticmethod + def poll(context): return True def execute(self, context): @@ -450,7 +463,8 @@ class netclientweb(bpy.types.Operator): bl_idname = "render.netclientweb" bl_label = "Open Master Monitor" - def poll(self, context): + @staticmethod + def poll(context): netsettings = context.scene.network_render return netsettings.server_address != "[default]" diff --git a/release/scripts/io/netrender/ui.py b/release/scripts/io/netrender/ui.py index 594ebcd12db..975f5c59edf 100644 --- a/release/scripts/io/netrender/ui.py +++ b/release/scripts/io/netrender/ui.py @@ -82,15 +82,17 @@ class RenderButtonsPanel(): bl_context = "render" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): - rd = context.scene.render - return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES) # Setting panel, use in the scene for now. class RENDER_PT_network_settings(bpy.types.Panel, RenderButtonsPanel): bl_label = "Network Settings" COMPAT_ENGINES = {'NET_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.use_game_engine==False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -125,10 +127,13 @@ class RENDER_PT_network_slave_settings(bpy.types.Panel, RenderButtonsPanel): bl_label = "Slave Settings" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_SLAVE") + ### return (super().poll(context) + ### and scene.network_render.mode == "RENDER_SLAVE") + ### FIXME ^^^ + return scene.network_render.mode == "RENDER_SLAVE" def draw(self, context): layout = self.layout @@ -150,10 +155,13 @@ class RENDER_PT_network_master_settings(bpy.types.Panel, RenderButtonsPanel): bl_label = "Master Settings" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_MASTER") + ### return (super().poll(context) + ### and scene.network_render.mode == "RENDER_MASTER") + ### ^^^ FIXME + return scene.network_render.mode == "RENDER_MASTER" def draw(self, context): layout = self.layout @@ -168,10 +176,13 @@ class RENDER_PT_network_job(bpy.types.Panel, RenderButtonsPanel): bl_label = "Job Settings" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_CLIENT") + ### return (super().poll(context) + ### and scene.network_render.mode == "RENDER_CLIENT") + ### ^^^ FIXME + return scene.network_render.mode == "RENDER_CLIENT" def draw(self, context): layout = self.layout @@ -208,14 +219,17 @@ class RENDER_PT_network_slaves(bpy.types.Panel, RenderButtonsPanel): bl_label = "Slaves Status" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): scene = context.scene netsettings = scene.network_render if netsettings.mode != "RENDER_CLIENT": return False verify_address(netsettings) - return (super().poll(context) - and netsettings.server_address != "[default]") + ### return (super().poll(context) + ### and netsettings.server_address != "[default]") + ### ^^^ FIXME + return netsettings.server_address != "[default]" def draw(self, context): layout = self.layout @@ -246,14 +260,16 @@ class RENDER_PT_network_slaves_blacklist(bpy.types.Panel, RenderButtonsPanel): bl_label = "Slaves Blacklist" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): scene = context.scene netsettings = scene.network_render if netsettings.mode != "RENDER_CLIENT": return False verify_address(netsettings) - return (super().poll(context) - and netsettings.server_address != "[default]") + ### return (super().poll(context) + ### and netsettings.server_address != "[default]") + return netsettings.server_address != "[default]" def draw(self, context): layout = self.layout @@ -283,14 +299,17 @@ class RENDER_PT_network_jobs(bpy.types.Panel, RenderButtonsPanel): bl_label = "Jobs" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): scene = context.scene netsettings = scene.network_render if netsettings.mode != "RENDER_CLIENT": return False verify_address(netsettings) - return (super().poll(context) - and netsettings.server_address != "[default]") + ### return (super().poll(context) + ### and netsettings.server_address != "[default]") + ### ^^^ FIXME + return netsettings.server_address != "[default]" def draw(self, context): layout = self.layout diff --git a/release/scripts/op/fcurve_euler_filter.py b/release/scripts/op/fcurve_euler_filter.py index 11431c52eb6..cc973d94e2a 100644 --- a/release/scripts/op/fcurve_euler_filter.py +++ b/release/scripts/op/fcurve_euler_filter.py @@ -48,7 +48,8 @@ class DiscontFilterOp(bpy.types.Operator): bl_idname = "graph.euler_filter" bl_label = "Filter out discontinuities in the active fcurves" - def poll(self, context): + @staticmethod + def poll(context): return context.active_object != None def execute(self, context): diff --git a/release/scripts/op/mesh.py b/release/scripts/op/mesh.py index ee3e93c58c4..1074ee7b482 100644 --- a/release/scripts/op/mesh.py +++ b/release/scripts/op/mesh.py @@ -28,7 +28,8 @@ class MeshSelectInteriorFaces(bpy.types.Operator): bl_label = "Select Interior Faces" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @staticmethod + def poll(context): ob = context.active_object return (ob and ob.type == 'MESH') @@ -69,7 +70,8 @@ class MeshMirrorUV(bpy.types.Operator): bl_label = "Copy Mirrored UV coords" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @staticmethod + def poll(context): ob = context.active_object return (ob and ob.type == 'MESH') diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index 8d9280e43af..e3ee4e00062 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -80,7 +80,8 @@ class SelectCamera(bpy.types.Operator): bl_label = "Select Camera" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @staticmethod + def poll(context): return context.scene.camera is not None def execute(self, context): @@ -109,7 +110,8 @@ class SelectHierarchy(bpy.types.Operator): extend = BoolProperty(name="Extend", description="Extend the existing selection", default=False) - def poll(self, context): + @staticmethod + def poll(context): return context.object def execute(self, context): @@ -167,7 +169,8 @@ class SubdivisionSet(bpy.types.Operator): relative = BoolProperty(name="Relative", description="Apply the subsurf level as an offset relative to the current level", default=False) - def poll(self, context): + @staticmethod + def poll(context): obs = context.selected_editable_objects return (obs is not None) @@ -379,7 +382,8 @@ class ShapeTransfer(bpy.types.Operator): return {'FINISHED'} - def poll(self, context): + @staticmethod + def poll(context): obj = context.active_object return (obj and obj.mode != 'EDIT') @@ -409,7 +413,8 @@ class JoinUVs(bpy.types.Operator): bl_idname = "object.join_uvs" bl_label = "Join as UVs" - def poll(self, context): + @staticmethod + def poll(context): obj = context.active_object return (obj and obj.type == 'MESH') @@ -467,7 +472,8 @@ class MakeDupliFace(bpy.types.Operator): bl_idname = "object.make_dupli_face" bl_label = "Make DupliFace" - def poll(self, context): + @staticmethod + def poll(context): obj = context.active_object return (obj and obj.type == 'MESH') diff --git a/release/scripts/op/object_align.py b/release/scripts/op/object_align.py index 39b642c1b9f..d156ccf37c0 100644 --- a/release/scripts/op/object_align.py +++ b/release/scripts/op/object_align.py @@ -263,7 +263,8 @@ class AlignObjects(bpy.types.Operator): align_z = BoolProperty(name="Align Z", description="Align in the Z axis", default=False) - def poll(self, context): + @staticmethod + def poll(context): return context.mode == 'OBJECT' def execute(self, context): diff --git a/release/scripts/op/sequencer.py b/release/scripts/op/sequencer.py index e01f2dcb23a..63480cae180 100644 --- a/release/scripts/op/sequencer.py +++ b/release/scripts/op/sequencer.py @@ -30,7 +30,8 @@ class SequencerCrossfadeSounds(bpy.types.Operator): bl_label = "Crossfade sounds" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @staticmethod + def poll(context): if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip: return context.scene.sequence_editor.active_strip.type == 'SOUND' else: @@ -83,7 +84,8 @@ class SequencerCutMulticam(bpy.types.Operator): camera = IntProperty(name="Camera", default=1, min=1, max=32, soft_min=1, soft_max=32) - def poll(self, context): + @staticmethod + def poll(context): if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip: return context.scene.sequence_editor.active_strip.type == 'MULTICAM' else: @@ -117,7 +119,8 @@ class SequencerDeinterlaceSelectedMovies(bpy.types.Operator): bl_label = "Deinterlace Movies" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @staticmethod + def poll(context): if context.scene and context.scene.sequence_editor: return True else: diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index 23e06c968cd..14d0b81a586 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -39,7 +39,8 @@ class ExportUVLayout(bpy.types.Operator): description="File format to export the UV layout to", default='SVG') - def poll(self, context): + @staticmethod + def poll(context): obj = context.active_object return (obj and obj.type == 'MESH') diff --git a/release/scripts/op/uvcalc_follow_active.py b/release/scripts/op/uvcalc_follow_active.py index 6f337bd623d..5aeae37aaf6 100644 --- a/release/scripts/op/uvcalc_follow_active.py +++ b/release/scripts/op/uvcalc_follow_active.py @@ -249,7 +249,8 @@ class FollowActiveQuads(bpy.types.Operator): description="Method to space UV edge loops", default="LENGTH") - def poll(self, context): + @staticmethod + def poll(context): obj = context.active_object return (obj is not None and obj.type == 'MESH') diff --git a/release/scripts/op/uvcalc_smart_project.py b/release/scripts/op/uvcalc_smart_project.py index 637dccda4ba..b52a2c41c26 100644 --- a/release/scripts/op/uvcalc_smart_project.py +++ b/release/scripts/op/uvcalc_smart_project.py @@ -1124,7 +1124,8 @@ class SmartProject(bpy.types.Operator): description="Margin to reduce bleed from adjacent islands.", default=0.0, min=0.0, max=1.0) - def poll(self, context): + @staticmethod + def poll(context): return context.active_object != None def execute(self, context): diff --git a/release/scripts/templates/operator.py b/release/scripts/templates/operator.py index 9cb544886da..9a875c6899e 100644 --- a/release/scripts/templates/operator.py +++ b/release/scripts/templates/operator.py @@ -23,7 +23,8 @@ class ExportSomeData(bpy.types.Operator): description="Choose between two items", default='OPT_A') - def poll(self, context): + @staticmethod + def poll(context): return context.active_object != None def execute(self, context): diff --git a/release/scripts/templates/operator_simple.py b/release/scripts/templates/operator_simple.py index e241afd23b7..55afe586a1e 100644 --- a/release/scripts/templates/operator_simple.py +++ b/release/scripts/templates/operator_simple.py @@ -9,7 +9,8 @@ class SimpleOperator(bpy.types.Operator): bl_idname = "object.simple_operator" bl_label = "Simple Object Operator" - def poll(self, context): + @staticmethod + def poll(context): return context.active_object != None def execute(self, context): diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py index f8c8e369ec8..f27f5300857 100644 --- a/release/scripts/templates/operator_uv.py +++ b/release/scripts/templates/operator_uv.py @@ -30,7 +30,8 @@ class UvOperator(bpy.types.Operator): bl_idname = "uv.simple_operator" bl_label = "Simple UV Operator" - def poll(self, context): + @staticmethod + def poll(context): obj = context.active_object return (obj and obj.type == 'MESH') diff --git a/release/scripts/ui/properties_data_armature.py b/release/scripts/ui/properties_data_armature.py index f32cbe97165..3dc1b47b3ef 100644 --- a/release/scripts/ui/properties_data_armature.py +++ b/release/scripts/ui/properties_data_armature.py @@ -28,7 +28,8 @@ class DataButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): return context.armature @@ -127,7 +128,8 @@ class DATA_PT_display(DataButtonsPanel, bpy.types.Panel): class DATA_PT_bone_groups(DataButtonsPanel, bpy.types.Panel): bl_label = "Bone Groups" - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type == 'ARMATURE' and context.object.pose) def draw(self, context): @@ -211,7 +213,8 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel, bpy.types.Panel): bl_label = "iTaSC parameters" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): ob = context.object return (ob and ob.pose) @@ -267,7 +270,8 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): #bl_label = "Bones Motion Paths" bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): # XXX: include posemode check? return (context.object) and (context.armature) @@ -295,7 +299,8 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # inhe #bl_label = "Bones Onion Skinning" bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): # XXX: include posemode check? return (context.object) and (context.armature) diff --git a/release/scripts/ui/properties_data_armature_rigify.py b/release/scripts/ui/properties_data_armature_rigify.py index 8331f2d517b..f8c387209c6 100644 --- a/release/scripts/ui/properties_data_armature_rigify.py +++ b/release/scripts/ui/properties_data_armature_rigify.py @@ -44,7 +44,8 @@ class DATA_PT_template(bpy.types.Panel): templates = [] - def poll(self, context): + @staticmethod + def poll(context): if not context.armature: return False obj = context.object @@ -262,7 +263,8 @@ class ActiveAssign(bpy.types.Operator): bl_idname = "pose.metarig_assign" bl_label = "Assign to the active posebone" - def poll(self, context): + @staticmethod + def poll(context): bone = context.active_pose_bone return bool(bone and bone.id_data.mode == 'POSE') @@ -280,7 +282,8 @@ class ActiveClear(bpy.types.Operator): bl_idname = "pose.metarig_clear" bl_label = "Metarig Clear Type" - def poll(self, context): + @staticmethod + def poll(context): bone = context.active_pose_bone return bool(bone and bone.id_data.mode == 'POSE') diff --git a/release/scripts/ui/properties_data_bone.py b/release/scripts/ui/properties_data_bone.py index d68253aac4d..39e27ed6e20 100644 --- a/release/scripts/ui/properties_data_bone.py +++ b/release/scripts/ui/properties_data_bone.py @@ -28,7 +28,8 @@ class BoneButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "bone" - def poll(self, context): + @staticmethod + def poll(context): return (context.bone or context.edit_bone) @@ -132,7 +133,8 @@ class BONE_PT_transform_locks(BoneButtonsPanel, bpy.types.Panel): bl_label = "Transform Locks" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.bone def draw(self, context): @@ -209,7 +211,8 @@ class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel): class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel): bl_label = "Display" - def poll(self, context): + @staticmethod + def poll(context): return context.bone def draw(self, context): @@ -246,7 +249,8 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel, bpy.types.Panel): bl_label = "Inverse Kinematics" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.active_pose_bone def draw(self, context): diff --git a/release/scripts/ui/properties_data_camera.py b/release/scripts/ui/properties_data_camera.py index 5152e004f28..15d513b5a25 100644 --- a/release/scripts/ui/properties_data_camera.py +++ b/release/scripts/ui/properties_data_camera.py @@ -28,16 +28,17 @@ class DataButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): - engine = context.scene.render.engine - return context.camera and (engine in self.COMPAT_ENGINES) - class DATA_PT_context_camera(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.camera and (engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -65,11 +66,21 @@ class DATA_PT_custom_props_camera(DataButtonsPanel, PropertyPanel, bpy.types.Pan _context_path = "object.data" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + @staticmethod + def poll(context): + engine = context.scene.render.engine + return context.camera and (engine in __class__.COMPAT_ENGINES) + class DATA_PT_camera(DataButtonsPanel, bpy.types.Panel): bl_label = "Lens" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + @staticmethod + def poll(context): + engine = context.scene.render.engine + return context.camera and (engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -131,6 +142,11 @@ class DATA_PT_camera_display(DataButtonsPanel, bpy.types.Panel): bl_label = "Display" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + @staticmethod + def poll(context): + engine = context.scene.render.engine + return context.camera and (engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/properties_data_curve.py b/release/scripts/ui/properties_data_curve.py index 279301ae330..32dfc815b6e 100644 --- a/release/scripts/ui/properties_data_curve.py +++ b/release/scripts/ui/properties_data_curve.py @@ -28,21 +28,24 @@ class DataButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type in ('CURVE', 'SURFACE', 'TEXT') and context.curve) class DataButtonsPanelCurve(DataButtonsPanel): '''Same as above but for curves only''' - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type == 'CURVE' and context.curve) class DataButtonsPanelActive(DataButtonsPanel): '''Same as above but for curves only''' - def poll(self, context): + @staticmethod + def poll(context): curve = context.curve return (curve and type(curve) is not bpy.types.TextCurve and curve.splines.active) @@ -133,7 +136,8 @@ class DATA_PT_shape_curve(DataButtonsPanel, bpy.types.Panel): class DATA_PT_geometry_curve(DataButtonsPanel, bpy.types.Panel): bl_label = "Geometry" - def poll(self, context): + @staticmethod + def poll(context): obj = context.object if obj and obj.type == 'SURFACE': return False @@ -270,7 +274,8 @@ class DATA_PT_active_spline(DataButtonsPanelActive, bpy.types.Panel): class DATA_PT_font(DataButtonsPanel, bpy.types.Panel): bl_label = "Font" - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type == 'TEXT' and context.curve) def draw(self, context): @@ -332,7 +337,8 @@ class DATA_PT_font(DataButtonsPanel, bpy.types.Panel): class DATA_PT_paragraph(DataButtonsPanel, bpy.types.Panel): bl_label = "Paragraph" - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type == 'TEXT' and context.curve) def draw(self, context): @@ -365,7 +371,8 @@ class DATA_PT_paragraph(DataButtonsPanel, bpy.types.Panel): class DATA_PT_textboxes(DataButtonsPanel, bpy.types.Panel): bl_label = "Text Boxes" - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type == 'TEXT' and context.curve) def draw(self, context): diff --git a/release/scripts/ui/properties_data_empty.py b/release/scripts/ui/properties_data_empty.py index 0a246f237a8..31fb4b4a625 100644 --- a/release/scripts/ui/properties_data_empty.py +++ b/release/scripts/ui/properties_data_empty.py @@ -27,7 +27,8 @@ class DataButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): return (context.object and context.object.type == 'EMPTY') diff --git a/release/scripts/ui/properties_data_lamp.py b/release/scripts/ui/properties_data_lamp.py index e72739f5ec7..a67d7c8fc87 100644 --- a/release/scripts/ui/properties_data_lamp.py +++ b/release/scripts/ui/properties_data_lamp.py @@ -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 diff --git a/release/scripts/ui/properties_data_lattice.py b/release/scripts/ui/properties_data_lattice.py index 4bc6d9865e0..972dc18977a 100644 --- a/release/scripts/ui/properties_data_lattice.py +++ b/release/scripts/ui/properties_data_lattice.py @@ -28,7 +28,8 @@ class DataButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): return context.lattice diff --git a/release/scripts/ui/properties_data_mesh.py b/release/scripts/ui/properties_data_mesh.py index b3d5215db58..e5a0f773df4 100644 --- a/release/scripts/ui/properties_data_mesh.py +++ b/release/scripts/ui/properties_data_mesh.py @@ -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 diff --git a/release/scripts/ui/properties_data_metaball.py b/release/scripts/ui/properties_data_metaball.py index 1cce0cea66f..215ca207bc9 100644 --- a/release/scripts/ui/properties_data_metaball.py +++ b/release/scripts/ui/properties_data_metaball.py @@ -28,7 +28,8 @@ class DataButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @staticmethod + def poll(context): return context.meta_ball @@ -95,7 +96,8 @@ class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel): class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel): bl_label = "Active Element" - def poll(self, context): + @staticmethod + def poll(context): return (context.meta_ball and context.meta_ball.active_element) def draw(self, context): diff --git a/release/scripts/ui/properties_game.py b/release/scripts/ui/properties_game.py index b12f368f5f4..ff618965d59 100644 --- a/release/scripts/ui/properties_game.py +++ b/release/scripts/ui/properties_game.py @@ -27,16 +27,17 @@ class PhysicsButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): - ob = context.active_object - rd = context.scene.render - return ob and ob.game and (rd.engine in self.COMPAT_ENGINES) - class PHYSICS_PT_game_physics(PhysicsButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + ob = context.active_object + rd = context.scene.render + return ob and ob.game and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -166,10 +167,11 @@ class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, bpy.types.Panel): bl_label = "Collision Bounds" COMPAT_ENGINES = {'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): game = context.object.game rd = context.scene.render - return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in self.COMPAT_ENGINES) + return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in __class__.COMPAT_ENGINES) def draw_header(self, context): game = context.active_object.game @@ -203,15 +205,16 @@ class RenderButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "render" - def poll(self, context): - rd = context.scene.render - return (rd.engine in self.COMPAT_ENGINES) - class RENDER_PT_game(RenderButtonsPanel, bpy.types.Panel): bl_label = "Game" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -224,6 +227,11 @@ class RENDER_PT_game_player(RenderButtonsPanel, bpy.types.Panel): bl_label = "Standalone Player" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -262,6 +270,11 @@ class RENDER_PT_game_stereo(RenderButtonsPanel, bpy.types.Panel): bl_label = "Stereo" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -322,6 +335,11 @@ class RENDER_PT_game_shading(RenderButtonsPanel, bpy.types.Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -351,6 +369,11 @@ class RENDER_PT_game_performance(RenderButtonsPanel, bpy.types.Panel): bl_label = "Performance" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -377,6 +400,11 @@ class RENDER_PT_game_sound(RenderButtonsPanel, bpy.types.Panel): bl_label = "Sound" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + rd = context.scene.render + return (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -396,17 +424,14 @@ class WorldButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "world" - def poll(self, context): - scene = context.scene - return (scene.render.engine in self.COMPAT_ENGINES) and (scene.world is not None) - class WORLD_PT_game_context_world(WorldButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): rd = context.scene.render return (context.scene) and (rd.use_game_engine) @@ -435,6 +460,11 @@ class WORLD_PT_game_world(WorldButtonsPanel, bpy.types.Panel): bl_label = "World" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + scene = context.scene + return (scene.world and scene.render.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -455,6 +485,11 @@ class WORLD_PT_game_mist(WorldButtonsPanel, bpy.types.Panel): bl_label = "Mist" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + scene = context.scene + return (scene.world and scene.render.engine in __class__.COMPAT_ENGINES) + def draw_header(self, context): world = context.world @@ -481,6 +516,11 @@ class WORLD_PT_game_physics(WorldButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + scene = context.scene + return (scene.world and scene.render.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/properties_material.py b/release/scripts/ui/properties_material.py index a464249b3b0..32070dfbacf 100644 --- a/release/scripts/ui/properties_material.py +++ b/release/scripts/ui/properties_material.py @@ -60,11 +60,6 @@ class MaterialButtonsPanel(): bl_context = "material" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): - mat = context.material - engine = context.scene.render.engine - return mat and (engine in self.COMPAT_ENGINES) - class MATERIAL_PT_preview(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Preview" @@ -79,12 +74,13 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, bpy.types.Panel): bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): # An exception, dont call the parent poll func because # this manages materials for all engine types engine = context.scene.render.engine - return (context.material or context.object) and (engine in self.COMPAT_ENGINES) + return (context.material or context.object) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -145,15 +141,20 @@ class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, bpy.types.Pa COMPAT_ENGINES = {'BLENDER_RENDER'} _context_path = "material" + @staticmethod + def poll(context): + return context.material and (context.scene.render.engine in __class__.COMPAT_ENGINES) + class MATERIAL_PT_shading(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -189,10 +190,11 @@ class MATERIAL_PT_strand(MaterialButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -237,6 +239,10 @@ class MATERIAL_PT_physics(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} + @staticmethod + def poll(context): + return context.material and (context.scene.render.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -261,10 +267,11 @@ class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Options" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -307,10 +314,11 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -343,10 +351,11 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Diffuse" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -414,10 +423,11 @@ class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Specular" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -484,10 +494,11 @@ class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw_header(self, context): mat = active_node_mat(context.material) @@ -536,10 +547,11 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw_header(self, context): raym = active_node_mat(context.material).raytrace_mirror @@ -596,10 +608,11 @@ class MATERIAL_PT_transp(MaterialButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in __class__.COMPAT_ENGINES) def draw_header(self, context): mat = active_node_mat(context.material) @@ -663,10 +676,11 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_GAME'} - def poll(self, context): + @staticmethod + def poll(context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (engine in self.COMPAT_ENGINES) + return mat and (engine in __class__.COMPAT_ENGINES) def draw_header(self, context): mat = active_node_mat(context.material) @@ -697,10 +711,11 @@ class MATERIAL_PT_halo(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Halo" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES) + return mat and (mat.type == 'HALO') and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -747,10 +762,11 @@ class MATERIAL_PT_flare(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Flare" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES) + return mat and (mat.type == 'HALO') and (engine in __class__.COMPAT_ENGINES) def draw_header(self, context): halo = context.material.halo @@ -782,11 +798,13 @@ class VolumeButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "material" + COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES) + return mat and (mat.type == 'VOLUME') and (engine in __class__.COMPAT_ENGINES) class MATERIAL_PT_volume_density(VolumeButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/ui/properties_object.py b/release/scripts/ui/properties_object.py index f09de20c8f3..603ac76120d 100644 --- a/release/scripts/ui/properties_object.py +++ b/release/scripts/ui/properties_object.py @@ -308,7 +308,8 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): #bl_label = "Object Motion Paths" bl_context = "object" - def poll(self, context): + @staticmethod + def poll(context): return (context.object) def draw(self, context): @@ -335,7 +336,8 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # in #bl_label = "Object Onion Skinning" bl_context = "object" - def poll(self, context): + @staticmethod + def poll(context): return (context.object) def draw(self, context): diff --git a/release/scripts/ui/properties_object_constraint.py b/release/scripts/ui/properties_object_constraint.py index bc8fd6ad9da..b5352abafa7 100644 --- a/release/scripts/ui/properties_object_constraint.py +++ b/release/scripts/ui/properties_object_constraint.py @@ -753,7 +753,8 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): bl_label = "Object Constraints" bl_context = "constraint" - def poll(self, context): + @staticmethod + def poll(context): return (context.object) def draw(self, context): @@ -771,7 +772,8 @@ class BONE_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): bl_label = "Bone Constraints" bl_context = "bone_constraint" - def poll(self, context): + @staticmethod + def poll(context): return (context.pose_bone) def draw(self, context): diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index ed516b49dea..e135b12b844 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -32,14 +32,14 @@ def particle_panel_enabled(context, psys): return (psys.point_cache.baked is False) and (not psys.edited) and (not context.particle_system_editable) -def particle_panel_poll(panel, context): +def particle_panel_poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in panel.COMPAT_ENGINES) + return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in cls.COMPAT_ENGINES) class ParticleButtonsPanel(): @@ -47,18 +47,16 @@ class ParticleButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "particle" - def poll(self, context): - return particle_panel_poll(self, context) - class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): engine = context.scene.render.engine - return (context.particle_system or context.object) and (engine in self.COMPAT_ENGINES) + return (context.particle_system or context.object) and (engine in __class__.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -140,13 +138,18 @@ class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, bpy.types.Pa COMPAT_ENGINES = {'BLENDER_RENDER'} _context_path = "particle_system.settings" + @staticmethod + def poll(context): + return particle_panel_poll(__class__, context) + class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Emission" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @staticmethod + def poll(context): + if particle_panel_poll(PARTICLE_PT_emission, context): return not context.particle_system.point_cache.external else: return False @@ -208,14 +211,15 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return psys.settings.type == 'HAIR' and (engine in self.COMPAT_ENGINES) + return psys.settings.type == 'HAIR' and (engine in __class__.COMPAT_ENGINES) def draw_header(self, context): #cloth = context.cloth.collision_settings @@ -265,7 +269,8 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): psys = context.particle_system engine = context.scene.render.engine if psys is None: @@ -275,7 +280,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel): phystype = psys.settings.physics_type if phystype == 'NO' or phystype == 'KEYED': return False - return (psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)) and engine in self.COMPAT_ENGINES + return (psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)) and engine in __class__.COMPAT_ENGINES def draw(self, context): psys = context.particle_system @@ -287,8 +292,9 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Velocity" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @staticmethod + def poll(context): + if particle_panel_poll(PARTICLE_PT_velocity, context): psys = context.particle_system return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external else: @@ -334,8 +340,9 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Rotation" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @staticmethod + def poll(context): + if particle_panel_poll(PARTICLE_PT_rotation, context): psys = context.particle_system return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external else: @@ -380,8 +387,9 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @staticmethod + def poll(context): + if particle_panel_poll(PARTICLE_PT_physics, context): return not context.particle_system.point_cache.external else: return False @@ -577,7 +585,8 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Boid Brain" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): psys = context.particle_system engine = context.scene.render.engine if psys is None: @@ -586,7 +595,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, bpy.types.Panel): return False if psys.point_cache.external: return False - return psys.settings.physics_type == 'BOIDS' and engine in self.COMPAT_ENGINES + return psys.settings.physics_type == 'BOIDS' and engine in __class__.COMPAT_ENGINES def draw(self, context): layout = self.layout @@ -677,14 +686,15 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Render" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return engine in self.COMPAT_ENGINES + return engine in __class__.COMPAT_ENGINES def draw(self, context): layout = self.layout @@ -848,14 +858,15 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return engine in self.COMPAT_ENGINES + return engine in __class__.COMPAT_ENGINES def draw(self, context): layout = self.layout @@ -907,6 +918,10 @@ class PARTICLE_PT_children(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + return particle_panel_poll(__class__, context) + def draw(self, context): layout = self.layout @@ -992,6 +1007,10 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + return particle_panel_poll(__class__, context) + def draw(self, context): part = context.particle_system.settings effector_weights_ui(self, context, part.effector_weights) @@ -1005,6 +1024,10 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + return particle_panel_poll(__class__, context) + def draw(self, context): layout = self.layout @@ -1033,6 +1056,10 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + return particle_panel_poll(__class__, context) + def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/properties_physics_cloth.py b/release/scripts/ui/properties_physics_cloth.py index af393c0d239..5845253db11 100644 --- a/release/scripts/ui/properties_physics_cloth.py +++ b/release/scripts/ui/properties_physics_cloth.py @@ -45,7 +45,8 @@ class PhysicButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @staticmethod + def poll(context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) @@ -137,7 +138,8 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Cache" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.cloth def draw(self, context): @@ -149,7 +151,8 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Collision" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.cloth def draw_header(self, context): @@ -189,7 +192,8 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Stiffness Scaling" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.cloth def draw_header(self, context): @@ -226,7 +230,8 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Field Weights" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return (context.cloth) def draw(self, context): diff --git a/release/scripts/ui/properties_physics_field.py b/release/scripts/ui/properties_physics_field.py index 963fbe08226..58537847b8a 100644 --- a/release/scripts/ui/properties_physics_field.py +++ b/release/scripts/ui/properties_physics_field.py @@ -31,7 +31,8 @@ class PhysicButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @staticmethod + def poll(context): rd = context.scene.render return (context.object) and (not rd.use_game_engine) @@ -173,7 +174,8 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Collision" #bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) diff --git a/release/scripts/ui/properties_physics_fluid.py b/release/scripts/ui/properties_physics_fluid.py index c24052c59fe..110e652a9ee 100644 --- a/release/scripts/ui/properties_physics_fluid.py +++ b/release/scripts/ui/properties_physics_fluid.py @@ -27,7 +27,8 @@ class PhysicButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @staticmethod + def poll(context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) @@ -220,9 +221,10 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Domain World" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.fluid - return md and (md.settings.type == 'DOMAIN') + return md and md.settings and (md.settings.type == 'DOMAIN') def draw(self, context): layout = self.layout @@ -271,9 +273,10 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Domain Boundary" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.fluid - return md and (md.settings.type == 'DOMAIN') + return md and md.settings and (md.settings.type == 'DOMAIN') def draw(self, context): layout = self.layout @@ -300,9 +303,10 @@ class PHYSICS_PT_domain_particles(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Domain Particles" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.fluid - return md and (md.settings.type == 'DOMAIN') + return md and md.settings and (md.settings.type == 'DOMAIN') def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/properties_physics_smoke.py b/release/scripts/ui/properties_physics_smoke.py index 5709a239858..a05226b3845 100644 --- a/release/scripts/ui/properties_physics_smoke.py +++ b/release/scripts/ui/properties_physics_smoke.py @@ -31,7 +31,8 @@ class PhysicButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @staticmethod + def poll(context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) @@ -130,7 +131,8 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke Groups" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') @@ -159,7 +161,8 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke Cache" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') @@ -179,7 +182,8 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke High Resolution" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') @@ -215,7 +219,8 @@ class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke High Resolution Cache" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') and md.domain_settings.highres @@ -235,7 +240,8 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke Field Weights" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): smoke = context.smoke return (smoke and smoke.smoke_type == 'DOMAIN') diff --git a/release/scripts/ui/properties_physics_softbody.py b/release/scripts/ui/properties_physics_softbody.py index 5e7aae26630..e7dc39bbaf7 100644 --- a/release/scripts/ui/properties_physics_softbody.py +++ b/release/scripts/ui/properties_physics_softbody.py @@ -35,7 +35,8 @@ class PhysicButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @staticmethod + def poll(context): ob = context.object rd = context.scene.render # return (ob and ob.type == 'MESH') and (not rd.use_game_engine) @@ -92,7 +93,8 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Cache" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.soft_body def draw(self, context): @@ -104,7 +106,8 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Goal" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.soft_body def draw_header(self, context): @@ -148,7 +151,8 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Edges" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.soft_body def draw_header(self, context): @@ -203,7 +207,8 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Self Collision" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.soft_body def draw_header(self, context): @@ -238,7 +243,8 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Solver" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return context.soft_body def draw(self, context): @@ -275,7 +281,8 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Field Weights" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return (context.soft_body) def draw(self, context): diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index 4e6596957d7..dc0b76645ae 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -42,15 +42,16 @@ class RenderButtonsPanel(): bl_context = "render" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): - rd = context.scene.render - return (context.scene and rd.use_game_engine is False) and (rd.engine in self.COMPAT_ENGINES) - class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel): bl_label = "Render" COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -74,6 +75,11 @@ class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -178,6 +184,11 @@ class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -204,6 +215,11 @@ class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -248,6 +264,11 @@ class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -291,6 +312,11 @@ class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel): bl_label = "Output" COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -412,7 +438,8 @@ class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @staticmethod + def poll(context): rd = context.scene.render return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA') @@ -483,6 +510,11 @@ class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel): bl_label = "Anti-Aliasing" COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw_header(self, context): rd = context.scene.render @@ -514,6 +546,11 @@ class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw_header(self, context): rd = context.scene.render @@ -533,6 +570,11 @@ class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel): bl_label = "Dimensions" COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout @@ -581,6 +623,11 @@ class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw_header(self, context): rd = context.scene.render @@ -627,6 +674,11 @@ class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel): bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @staticmethod + def poll(context): + rd = context.scene.render + return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES) + def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/properties_scene.py b/release/scripts/ui/properties_scene.py index 859fcc3ce47..a92df6f8203 100644 --- a/release/scripts/ui/properties_scene.py +++ b/release/scripts/ui/properties_scene.py @@ -28,7 +28,8 @@ class SceneButtonsPanel(): bl_region_type = 'WINDOW' bl_context = "scene" - def poll(self, context): + @staticmethod + def poll(context): return context.scene @@ -118,7 +119,8 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): bl_label = "Active Keying Set" - def poll(self, context): + @staticmethod + def poll(context): return (context.scene.active_keying_set and context.scene.active_keying_set.absolute) def draw(self, context): diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index d9d8e5cb24d..aeccbc71e46 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -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 diff --git a/release/scripts/ui/properties_world.py b/release/scripts/ui/properties_world.py index fe1c085dc02..5179fc5f0d2 100644 --- a/release/scripts/ui/properties_world.py +++ b/release/scripts/ui/properties_world.py @@ -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' diff --git a/release/scripts/ui/space_console.py b/release/scripts/ui/space_console.py index f2c757adaf5..dbe08c16a77 100644 --- a/release/scripts/ui/space_console.py +++ b/release/scripts/ui/space_console.py @@ -138,7 +138,8 @@ class ConsoleAutocomplete(bpy.types.Operator): bl_idname = "console.autocomplete" bl_label = "Console Autocomplete" - def poll(self, context): + @staticmethod + def poll(context): return context.space_data.console_type != 'REPORT' def execute(self, context): diff --git a/release/scripts/ui/space_image.py b/release/scripts/ui/space_image.py index a51d237019a..eafe2d183f6 100644 --- a/release/scripts/ui/space_image.py +++ b/release/scripts/ui/space_image.py @@ -335,7 +335,8 @@ class IMAGE_PT_image_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Image" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return (sima.image) @@ -354,7 +355,8 @@ class IMAGE_PT_game_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Game Properties" - def poll(self, context): + @staticmethod + def poll(context): rd = context.scene.render sima = context.space_data return (sima and sima.image) and (rd.engine == 'BLENDER_GAME') @@ -399,7 +401,8 @@ class IMAGE_PT_view_histogram(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Histogram" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return (sima and sima.image) @@ -417,7 +420,8 @@ class IMAGE_PT_view_waveform(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Waveform" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return (sima and sima.image) @@ -436,7 +440,8 @@ class IMAGE_PT_view_vectorscope(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Vectorscope" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return (sima and sima.image) @@ -453,7 +458,8 @@ class IMAGE_PT_sample_line(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Sample Line" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return (sima and sima.image) @@ -470,7 +476,8 @@ class IMAGE_PT_scope_sample(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Scope Samples" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return sima @@ -490,7 +497,8 @@ class IMAGE_PT_view_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Display" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return (sima and (sima.image or sima.show_uvedit)) @@ -553,7 +561,8 @@ class IMAGE_PT_paint(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Paint" - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data return sima.show_paint @@ -598,7 +607,8 @@ class IMAGE_PT_tools_brush_texture(bpy.types.Panel): bl_label = "Texture" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data toolsettings = context.tool_settings.image_paint return sima.show_paint and toolsettings.brush @@ -622,7 +632,8 @@ class IMAGE_PT_paint_stroke(bpy.types.Panel): bl_label = "Paint Stroke" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data toolsettings = context.tool_settings.image_paint return sima.show_paint and toolsettings.brush @@ -653,7 +664,8 @@ class IMAGE_PT_paint_curve(bpy.types.Panel): bl_label = "Paint Curve" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): sima = context.space_data toolsettings = context.tool_settings.image_paint return sima.show_paint and toolsettings.brush diff --git a/release/scripts/ui/space_logic.py b/release/scripts/ui/space_logic.py index 4a70695024a..370e49c4475 100644 --- a/release/scripts/ui/space_logic.py +++ b/release/scripts/ui/space_logic.py @@ -25,7 +25,8 @@ class LOGIC_PT_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Properties" - def poll(self, context): + @staticmethod + def poll(context): ob = context.active_object return ob and ob.game diff --git a/release/scripts/ui/space_sequencer.py b/release/scripts/ui/space_sequencer.py index 0aaf25635b6..bad731f61bf 100644 --- a/release/scripts/ui/space_sequencer.py +++ b/release/scripts/ui/space_sequencer.py @@ -319,7 +319,8 @@ class SequencerButtonsPanel(): def has_sequencer(self, context): return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW') - def poll(self, context): + @staticmethod + def poll(context): return self.has_sequencer(context) and (act_strip(context) is not None) @@ -330,7 +331,8 @@ class SequencerButtonsPanel_Output(): def has_preview(self, context): return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW') - def poll(self, context): + @staticmethod + def poll(context): return self.has_preview(context) @@ -384,7 +386,8 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel): class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Effect Strip" - def poll(self, context): + @staticmethod + def poll(context): if not self.has_sequencer(context): return False @@ -513,7 +516,8 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Strip Input" - def poll(self, context): + @staticmethod + def poll(context): if not self.has_sequencer(context): return False @@ -587,7 +591,8 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): class SEQUENCER_PT_sound(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Sound" - def poll(self, context): + @staticmethod + def poll(context): if not self.has_sequencer(context): return False @@ -627,7 +632,8 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel, bpy.types.Panel): class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Scene" - def poll(self, context): + @staticmethod + def poll(context): if not self.has_sequencer(context): return False @@ -651,7 +657,8 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Filter" - def poll(self, context): + @staticmethod + def poll(context): if not self.has_sequencer(context): return False @@ -712,7 +719,8 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): class SEQUENCER_PT_proxy(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Proxy" - def poll(self, context): + @staticmethod + def poll(context): if not self.has_sequencer(context): return False diff --git a/release/scripts/ui/space_text.py b/release/scripts/ui/space_text.py index 85c2b43859d..cdc1dcb12c3 100644 --- a/release/scripts/ui/space_text.py +++ b/release/scripts/ui/space_text.py @@ -246,7 +246,8 @@ class TEXT_MT_edit_to3d(bpy.types.Menu): class TEXT_MT_edit(bpy.types.Menu): bl_label = "Edit" - def poll(self, context): + @staticmethod + def poll(context): return (context.space_data.text) def draw(self, context): diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index 9cdf6ca2809..8fa8b56f759 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -142,7 +142,8 @@ class USERPREF_PT_interface(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'INTERFACE') @@ -242,7 +243,8 @@ class USERPREF_PT_edit(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'EDITING') @@ -356,7 +358,8 @@ class USERPREF_PT_system(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'SYSTEM') @@ -520,7 +523,8 @@ class USERPREF_PT_theme(bpy.types.Panel): for i, attr in enumerate(props_ls): colsub_pair[i % 2].row().prop(themedata, attr) - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'THEMES') @@ -652,7 +656,8 @@ class USERPREF_PT_file(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'FILES') @@ -723,7 +728,8 @@ class USERPREF_PT_input(InputKeyMapPanel): bl_space_type = 'USER_PREFERENCES' bl_label = "Input" - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'INPUT') @@ -817,7 +823,8 @@ class USERPREF_PT_addons(bpy.types.Panel): _addons_fake_modules = {} - def poll(self, context): + @staticmethod + def poll(context): userpref = context.user_preferences return (userpref.active_section == 'ADDONS') diff --git a/release/scripts/ui/space_userpref_keymap.py b/release/scripts/ui/space_userpref_keymap.py index a76b7249d5d..460ae88d1f7 100644 --- a/release/scripts/ui/space_userpref_keymap.py +++ b/release/scripts/ui/space_userpref_keymap.py @@ -763,7 +763,8 @@ class WM_OT_keyconfig_remove(bpy.types.Operator): bl_idname = "wm.keyconfig_remove" bl_label = "Remove Key Config" - def poll(self, context): + @staticmethod + def poll(context): wm = context.manager return wm.active_keyconfig.user_defined diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 446cf2d5fce..e89604de1dd 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -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) diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index faa5c0324bf..24fb86066a7 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -473,7 +473,8 @@ class PaintPanel(): bl_space_type = 'VIEW_3D' bl_region_type = 'TOOLS' - def paint_settings(self, context): + @staticmethod + def paint_settings(context): ts = context.tool_settings if context.sculpt_object: @@ -493,13 +494,14 @@ class PaintPanel(): class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): bl_label = "Brush" - def poll(self, context): - return self.paint_settings(context) + @staticmethod + def poll(context): + return __class__.paint_settings(context) def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush if not context.particle_edit_object: @@ -720,15 +722,16 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): bl_label = "Texture" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @staticmethod + def poll(context): + settings = __class__.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or context.texture_paint_object)) def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush tex_slot = brush.texture_slot @@ -822,8 +825,9 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): bl_label = "Tool" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @staticmethod + def poll(context): + settings = __class__.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or context.texture_paint_object or context.vertex_paint_object or context.weight_paint_object)) @@ -831,7 +835,7 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush texture_paint = context.texture_paint_object sculpt = context.sculpt_object @@ -857,8 +861,9 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): bl_label = "Stroke" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @staticmethod + def poll(context): + settings = __class__.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or context.vertex_paint_object or context.weight_paint_object or @@ -867,7 +872,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush texture_paint = context.texture_paint_object @@ -954,14 +959,15 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel, bpy.types.Panel): bl_label = "Curve" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @staticmethod + def poll(context): + settings = __class__.paint_settings(context) return (settings and settings.brush and settings.brush.curve) def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush layout.template_curve_mapping(brush, "curve", brush=True) @@ -978,7 +984,8 @@ class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel): bl_label = "Options" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return (context.sculpt_object and context.tool_settings.sculpt) def draw(self, context): @@ -988,7 +995,7 @@ class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel): tool_settings = context.tool_settings sculpt = tool_settings.sculpt - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush split = layout.split() @@ -1020,7 +1027,8 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): bl_label = "Symmetry" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return (context.sculpt_object and context.tool_settings.sculpt) def draw(self, context): @@ -1029,7 +1037,7 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): layout = self.layout sculpt = context.tool_settings.sculpt - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush split = layout.split() @@ -1058,14 +1066,15 @@ class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel): bl_label = "Appearance" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.texture_paint_object and context.tool_settings.image_paint) def draw(self, context): layout = self.layout sculpt = context.tool_settings.sculpt - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush col = layout.column(); @@ -1177,7 +1186,8 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel): bl_context = "texturepaint" bl_label = "Project Paint" - def poll(self, context): + @staticmethod + def poll(context): brush = context.tool_settings.image_paint.brush return (brush and brush.imagepaint_tool != 'SMEAR') @@ -1247,7 +1257,8 @@ class VIEW3D_PT_imagepaint_options(PaintPanel): bl_label = "Options" bl_default_closed = True - def poll(self, context): + @staticmethod + def poll(context): return (context.texture_paint_object and context.tool_settings.image_paint) def draw(self, context): diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 080e01b4909..9ace62996ea 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -588,7 +588,7 @@ static void rna_def_panel(BlenderRNA *brna) /* poll */ func= RNA_def_function(srna, "poll", NULL); RNA_def_function_ui_description(func, "If this method returns a non-null output, then the panel can be drawn."); - RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); parm= RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -711,7 +711,7 @@ static void rna_def_menu(BlenderRNA *brna) /* poll */ func= RNA_def_function(srna, "poll", NULL); RNA_def_function_ui_description(func, "If this method returns a non-null output, then the menu can be drawn."); - RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); parm= RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 5df35ed4210..0f72cfa8b9d 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -186,7 +186,7 @@ void RNA_api_operator(StructRNA *srna) /* poll */ func= RNA_def_function(srna, "poll", NULL); RNA_def_function_ui_description(func, "Test if the operator can be called or not."); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); RNA_def_pointer(func, "context", "Context", "", ""); @@ -246,7 +246,7 @@ void RNA_api_macro(StructRNA *srna) /* poll */ func= RNA_def_function(srna, "poll", NULL); RNA_def_function_ui_description(func, "Test if the operator can be called or not."); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); RNA_def_pointer(func, "context", "Context", "", ""); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index a18c9f7e92d..1b49ed52e3d 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4388,7 +4388,7 @@ static int rna_function_arg_count(FunctionRNA *func) const ListBase *lb= RNA_function_defined_parameters(func); PropertyRNA *parm; Link *link; - int count= 1; + int count= (RNA_function_flag(func) & FUNC_NO_SELF) ? 0 : 1; for(link=lb->first; link; link=link->next) { parm= (PropertyRNA*)link; @@ -4537,6 +4537,7 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par ParameterIterator iter; PointerRNA funcptr; int err= 0, i, flag, ret_len=0; + int is_static = RNA_function_flag(func) & FUNC_NO_SELF; PropertyRNA *pret_single= NULL; void *retdata_single= NULL; @@ -4554,52 +4555,54 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par } bpy_context_set(C, &gilstate); - - /* exception, operators store their PyObjects for re-use */ - if(ptr->data) { - if(RNA_struct_is_a(ptr->type, &RNA_Operator)) { - wmOperator *op= ptr->data; - if(op->py_instance) { - py_class_instance= op->py_instance; - Py_INCREF(py_class_instance); - } - else { - /* store the instance here once its created */ - py_class_instance_store= &op->py_instance; + + if (!is_static) { + /* exception, operators store their PyObjects for re-use */ + if(ptr->data) { + if(RNA_struct_is_a(ptr->type, &RNA_Operator)) { + wmOperator *op= ptr->data; + if(op->py_instance) { + py_class_instance= op->py_instance; + Py_INCREF(py_class_instance); + } + else { + /* store the instance here once its created */ + py_class_instance_store= &op->py_instance; + } } } - } - /* end exception */ - - if(py_class_instance==NULL) - py_srna= pyrna_struct_CreatePyObject(ptr); - - if(py_class_instance) { - /* special case, instance is cached */ - } - else if(py_srna == NULL) { - py_class_instance = NULL; - } - else if(py_srna == Py_None) { /* probably wont ever happen but possible */ - Py_DECREF(py_srna); - py_class_instance = NULL; - } - else { - args = PyTuple_New(1); - PyTuple_SET_ITEM(args, 0, py_srna); - py_class_instance= PyObject_Call(py_class, args, NULL); - Py_DECREF(args); - - if(py_class_instance == NULL) { - err= -1; /* so the error is not overridden below */ + /* end exception */ + + if(py_class_instance==NULL) + py_srna= pyrna_struct_CreatePyObject(ptr); + + if(py_class_instance) { + /* special case, instance is cached */ + } + else if(py_srna == NULL) { + py_class_instance = NULL; } - else if(py_class_instance_store) { - *py_class_instance_store = py_class_instance; - Py_INCREF(py_class_instance); + else if(py_srna == Py_None) { /* probably wont ever happen but possible */ + Py_DECREF(py_srna); + py_class_instance = NULL; + } + else { + args = PyTuple_New(1); + PyTuple_SET_ITEM(args, 0, py_srna); + py_class_instance= PyObject_Call(py_class, args, NULL); + Py_DECREF(args); + + if(py_class_instance == NULL) { + err= -1; /* so the error is not overridden below */ + } + else if(py_class_instance_store) { + *py_class_instance_store = py_class_instance; + Py_INCREF(py_class_instance); + } } } - if (py_class_instance) { /* Initializing the class worked, now run its invoke function */ + if (is_static || py_class_instance) { /* Initializing the class worked, now run its invoke function */ PyObject *item= PyObject_GetAttrString(py_class, RNA_function_identifier(func)); // flag= RNA_function_flag(func); @@ -4607,12 +4610,19 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par RNA_pointer_create(NULL, &RNA_Function, func, &funcptr); args = PyTuple_New(rna_function_arg_count(func)); /* first arg is included in 'item' */ - PyTuple_SET_ITEM(args, 0, py_class_instance); + + if(is_static) { + i= 0; + } + else { + PyTuple_SET_ITEM(args, 0, py_class_instance); + i= 1; + } RNA_parameter_list_begin(parms, &iter); /* parse function parameters */ - for (i= 1; iter.valid; RNA_parameter_list_next(&iter)) { + for (; iter.valid; RNA_parameter_list_next(&iter)) { parm= iter.parm; flag= RNA_property_flag(parm); -- cgit v1.2.3