diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-12-27 19:35:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-12-27 19:35:15 +0300 |
commit | b7c7057f3e876cd0f964e2badc43e0b9a5e25d3b (patch) | |
tree | 1a311f3c23eb5a607bfe033c9f2cbab6955ce8a2 /source | |
parent | f0f451fc16880315c8c094aaabd0fbf8a06ffede (diff) |
* converting operator props to strings was using a float as in int.
* PyOperators were always calling the python functions with default args.
* Made operator prints only happen when G.f & G_DEBUG is enabled.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 11 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_opwrapper.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 4 |
4 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 1d29efa2463..7dce91d4ec4 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1899,7 +1899,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) break; case PROP_FLOAT: if (len==0) { - BLI_dynstr_appendf(dynstr, "%f", RNA_property_int_get(ptr, prop)); + BLI_dynstr_appendf(dynstr, "%f", RNA_property_float_get(ptr, prop)); } else { BLI_dynstr_append(dynstr, "("); diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index d0ced50e70f..b62693828a6 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -82,17 +82,16 @@ static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname ) if( strcmp( name, "__members__" ) == 0 ) { PyObject *item; - - ret = PyList_New(0); + ret = PyList_New(2); + + PyList_SET_ITEM(ret, 0, PyUnicode_FromString("add")); + PyList_SET_ITEM(ret, 1, PyUnicode_FromString("remove")); for(ot= WM_operatortype_first(); ot; ot= ot->next) { item = PyUnicode_FromString( ot->idname ); PyList_Append(ret, item); Py_DECREF(item); } - - item = PyUnicode_FromString("add"); PyList_Append(ret, item); Py_DECREF(item); - item = PyUnicode_FromString("remove"); PyList_Append(ret, item); Py_DECREF(item); } else if ( strcmp( name, "add" ) == 0 ) { ret= PYOP_wrap_add_func(); @@ -168,7 +167,7 @@ static PyObject * pyop_func_call(BPy_OperatorFunc * self, PyObject *args, PyObje error_val = 1; /* pyrna_py_to_prop sets the error */ break; } - + if (pyrna_py_to_prop(&ptr, prop, item)) { error_val= 1; break; diff --git a/source/blender/python/intern/bpy_opwrapper.c b/source/blender/python/intern/bpy_opwrapper.c index 89783ee3852..779f876390b 100644 --- a/source/blender/python/intern/bpy_opwrapper.c +++ b/source/blender/python/intern/bpy_opwrapper.c @@ -63,7 +63,7 @@ static void pyop_kwargs_from_operator(PyObject *dict, wmOperator *op) if (strcmp(arg_name, "rna_type")==0) continue; - item = pyrna_prop_to_py(&iter.ptr, prop); + item = pyrna_prop_to_py(op->ptr, prop); PyDict_SetItemString(dict, arg_name, item); Py_DECREF(item); } @@ -80,7 +80,7 @@ static int PYTHON_OT_exec(bContext *C, wmOperator *op) pyop_kwargs_from_operator(kw, op); ret = PyObject_Call(pyot->py_exec, args, kw); - + Py_DECREF(args); Py_DECREF(kw); @@ -176,10 +176,11 @@ static PyObject *pyop_add(PyObject *self, PyObject *args) char *name= NULL; PyObject *invoke= NULL; PyObject *exec= NULL; - - if (!PyArg_ParseTuple(args, "ssOO", &idname, &name, &invoke, &exec)) + + if (!PyArg_ParseTuple(args, "ssOO", &idname, &name, &invoke, &exec)) { PyErr_SetString( PyExc_AttributeError, "expected 2 strings and 2 function objects"); return NULL; + } if (WM_operatortype_find(idname)) { PyErr_Format( PyExc_AttributeError, "First argument \"%s\" operator alredy exists with this name", idname); @@ -190,7 +191,7 @@ static PyObject *pyop_add(PyObject *self, PyObject *args) PyErr_SetString( PyExc_AttributeError, "the 2nd arg must be a function or None, the secons must be a function"); return NULL; } - + pyot= MEM_callocN(sizeof(PyOperatorType), "PyOperatorType"); strcpy(pyot->idname, idname); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index ec22bbd365c..b0abdc3b7f2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -331,8 +331,8 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, I else printf("invalid operator call %s\n", ot->idname); /* debug, important to leave a while, should never happen */ - /* only for testing, can remove any time */ - WM_operator_print(op); + if(G.f & G_DEBUG) + WM_operator_print(op); if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) { wm_operator_register(wm, op); |