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/templates/operator.py | 3 ++- release/scripts/templates/operator_simple.py | 3 ++- release/scripts/templates/operator_uv.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'release/scripts/templates') 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') -- cgit v1.2.3