[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20810] branches/soc-2009-kazanbas/source/ blender/python/intern/bpy_operator_wrap.c: Pass context to the "invoke" operator method.
Arystanbek Dyussenov
arystan.d at gmail.com
Thu Jun 11 17:10:23 CEST 2009
Revision: 20810
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20810
Author: kazanbas
Date: 2009-06-11 17:10:23 +0200 (Thu, 11 Jun 2009)
Log Message:
-----------
Pass context to the "invoke" operator method.
"invoke" should have three args now: self, context and event respectively.
Modified Paths:
--------------
branches/soc-2009-kazanbas/source/blender/python/intern/bpy_operator_wrap.c
Modified: branches/soc-2009-kazanbas/source/blender/python/intern/bpy_operator_wrap.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/python/intern/bpy_operator_wrap.c 2009-06-11 13:42:41 UTC (rev 20809)
+++ branches/soc-2009-kazanbas/source/blender/python/intern/bpy_operator_wrap.c 2009-06-11 15:10:23 UTC (rev 20810)
@@ -190,7 +190,6 @@
PyObject *ret= NULL, *py_class_instance, *item= NULL;
int ret_flag= (mode==PYOP_POLL ? 0:OPERATOR_CANCELLED);
PointerRNA ptr_context;
- PyObject *py_context;
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -226,20 +225,23 @@
RNA_property_collection_end(&iter);
}
+
+ RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context);
-
if (mode==PYOP_INVOKE) {
item= PyObject_GetAttrString(py_class, "invoke");
- args = PyTuple_New(2);
- PyTuple_SET_ITEM(args, 1, pyop_dict_from_event(event));
+ args = PyTuple_New(3);
+
+ // PyTuple_SET_ITEM "steals" object reference, it is
+ // an object passed shouldn't be DECREF'ed
+ PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context));
+ PyTuple_SET_ITEM(args, 2, pyop_dict_from_event(event));
}
else if (mode==PYOP_EXEC) {
item= PyObject_GetAttrString(py_class, "exec");
args = PyTuple_New(2);
- RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context);
- py_context = pyrna_struct_CreatePyObject(&ptr_context);
- PyTuple_SET_ITEM(args, 1, py_context);
+ PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context));
}
else if (mode==PYOP_POLL) {
item= PyObject_GetAttrString(py_class, "poll");
@@ -398,7 +400,7 @@
{PYOP_ATTR_PROP, 'l', 0, BPY_CLASS_ATTR_OPTIONAL},
{PYOP_ATTR_DESCRIPTION, 's', 0, BPY_CLASS_ATTR_NONE_OK},
{"exec", 'f', 2, BPY_CLASS_ATTR_OPTIONAL},
- {"invoke", 'f', 2, BPY_CLASS_ATTR_OPTIONAL},
+ {"invoke", 'f', 3, BPY_CLASS_ATTR_OPTIONAL},
{"poll", 'f', 2, BPY_CLASS_ATTR_OPTIONAL},
{NULL, 0, 0, 0}
};
More information about the Bf-blender-cvs
mailing list