Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-11-04 15:59:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-04 15:59:03 +0300
commit64ff9d6de40740866c290f1e1e88e6e22a1ca5e7 (patch)
tree00b710119c7a21088fda1d9f833afff5b965fc37 /release/scripts/modules/bpy
parent0e8172368356943e0bae95ec4a8d4ecdc9dba793 (diff)
fix to allow [#24009] to be fixed.
WM_operator_poll() could fail in cases WM_operator_name_call() would succeed because calling the operator would setup the context before calling poll. this would result in python raising an invalid error or menu items being greyed out. now python can also check with an operator context: bpy.ops.object.editmode_toggle.poll('INVOKE_SCREEN')
Diffstat (limited to 'release/scripts/modules/bpy')
-rw-r--r--release/scripts/modules/bpy/ops.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index ba56fa12fe1..c6bdc21afa6 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -115,14 +115,34 @@ class bpy_ops_submodule_op(object):
def _get_doc(self):
return op_as_string(self.idname())
+ @staticmethod
+ def _parse_args(args):
+ C_dict = None
+ C_exec = 'EXEC_DEFAULT'
+
+ if len(args) == 0:
+ pass
+ elif len(args) == 1:
+ if type(args[0]) != str:
+ C_dict = args[0]
+ else:
+ C_exec = args[0]
+ elif len(args) == 2:
+ C_exec, C_dict = args
+ else:
+ raise ValueError("1 or 2 args execution context is supported")
+
+ return C_dict, C_exec
+
__doc__ = property(_get_doc)
def __init__(self, module, func):
self.module = module
self.func = func
- def poll(self, context=None):
- return op_poll(self.idname_py(), context)
+ def poll(self, *args):
+ C_dict, C_exec = __class__._parse_args(args)
+ return op_poll(self.idname_py(), C_dict, C_exec)
def idname(self):
# submod.foo -> SUBMOD_OT_foo
@@ -135,31 +155,11 @@ class bpy_ops_submodule_op(object):
def __call__(self, *args, **kw):
# Get the operator from blender
- if len(args) > 2:
- raise ValueError("1 or 2 args execution context is supported")
-
- C_dict = None
-
if args:
-
- C_exec = 'EXEC_DEFAULT'
-
- if len(args) == 2:
- C_exec = args[0]
- C_dict = args[1]
- else:
- if type(args[0]) != str:
- C_dict = args[0]
- else:
- C_exec = args[0]
-
- if len(args) == 2:
- C_dict = args[1]
-
+ C_dict, C_exec = __class__._parse_args(args)
ret = op_call(self.idname_py(), C_dict, kw, C_exec)
-
else:
- ret = op_call(self.idname_py(), C_dict, kw)
+ ret = op_call(self.idname_py(), None, kw)
if 'FINISHED' in ret:
import bpy