* converting operator props to strings was using a float as in int.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 27 Dec 2008 16:35:15 +0000 (16:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 27 Dec 2008 16:35:15 +0000 (16:35 +0000)
* PyOperators were always calling the python functions with default args.
* Made operator prints only happen when G.f & G_DEBUG is enabled.

source/blender/makesrna/intern/rna_access.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_opwrapper.c
source/blender/windowmanager/intern/wm_event_system.c

index 1d29efa2463d45d1d469f70c40b33d81e52dea4f..7dce91d4ec4306fa21071818edaa88c8c9e92a82 100644 (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, "(");
index d0ced50e70f2726ee70c1c68281fba4cfd12842d..b62693828a623df40c09b36cfd85f9e15bc21d61 100644 (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;
index 89783ee3852ee64706eb551e9e01dfdf38b0cc15..779f876390bef6034401affb08798d7c49680173 100644 (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);
index ec22bbd365c84f93085f94dc24e79cde287e9c5b..b0abdc3b7f23bd41a715efa17121315dc938c661 100644 (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);