* 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.
This commit is contained in:
2008-12-27 16:35:15 +00:00
parent f0f451fc16
commit b7c7057f3e
4 changed files with 14 additions and 14 deletions

View File

@@ -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, "(");

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);