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>2009-01-18 13:46:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-01-18 13:46:26 +0300
commit97692a3bf5a91e83e04c9864e3723f2363006111 (patch)
tree1c8c829b58732080184cdf89160c8de32cf0ad7b /source/blender/python
parent53ae509cc5ad75dca490dea8c632d542285e0058 (diff)
Changes to functions from blender/windowmanager/intern/wm_event_system.c
Python operator api was using WM_operator_name_call() which was confusing things too much. Added WM_operator_call_py() which ended up being a very small function and split out operator creation into wm_operator_create() Python operator now runs the poll() function and raises an error if it fails. Eventually there should be error messages for poll that python can use to give the exact reason for failing (eg - library linked data, no active object...)
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_operator.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index f800b7d0d04..fb1040fac18 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -194,6 +194,11 @@ static PyObject * pyop_func_call(BPy_OperatorFunc * self, PyObject *args, PyObje
return NULL;
}
+ if(ot->poll && (ot->poll(self->C) == 0)) {
+ PyErr_SetString( PyExc_SystemError, "Operator poll() function failed, context is incorrect");
+ return NULL;
+ }
+
WM_operator_properties_create(&ptr, self->name);
error_val= PYOP_props_from_dict(&ptr, kw);
@@ -203,7 +208,7 @@ static PyObject * pyop_func_call(BPy_OperatorFunc * self, PyObject *args, PyObje
BKE_reports_init(&reports, RPT_STORE);
- WM_operator_name_call(self->C, self->name, WM_OP_EXEC_DEFAULT, &ptr, &reports);
+ WM_operator_call_py(self->C, ot, &ptr, &reports);
report_str= BKE_reports_string(&reports, RPT_ERROR);