bugfix [#23182] Using self.report() inside poll() gives crash

poll() function is now a static method in python, this is more correct, matching C where the operator is not created to run poll.


    def poll(self, context): ...

is now...

    @staticmethod
    def poll(context): ...

Pythons way of doing static methods is a bit odd but cant be helped :|

This does make subclassing poll functions with COMPAT_ENGINES break, so had to modify quite a few scripts for this.
This commit is contained in:
2010-08-05 16:05:30 +00:00
parent 5d18274cac
commit 163f6055d2
54 changed files with 845 additions and 368 deletions

View File

@@ -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]"

View File

@@ -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