user interface units, off by default.
[blender.git] / source / blender / python / intern / bpy_operator_wrap.c
index 02d721739e76df993b045fcbcc3495ae14d383aa..9a74bf0aee8af22e37dd943a38bcbd03e4a1e753 100644 (file)
@@ -37,7 +37,6 @@
 #include "RNA_define.h"
 
 #include "bpy_rna.h"
-#include "bpy_compat.h"
 #include "bpy_util.h"
 
 #include "../generic/bpy_internal_import.h" // our own imports
@@ -93,11 +92,9 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
        PointerRNA ptr_event;
        PyObject *py_operator;
 
-       PyGILState_STATE gilstate = PyGILState_Ensure();
+       PyGILState_STATE gilstate;
 
-       bpy_import_main_set(CTX_data_main(C));
-       
-       BPY_update_modules(); // XXX - the RNA pointers can change so update before running, would like a nicer solutuon for this.
+       bpy_context_set(C, &gilstate);
 
        args = PyTuple_New(1);
        PyTuple_SET_ITEM(args, 0, PyObject_GetAttrString(py_class, "__rna__")); // need to use an rna instance as the first arg
@@ -221,8 +218,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
        }
 #endif
 
-       PyGILState_Release(gilstate);
-       bpy_import_main_set(NULL);
+       bpy_context_clear(C, &gilstate);
 
        return ret_flag;
 }
@@ -265,8 +261,8 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
        }
 
        item= PyObject_GetAttrString(py_class, PYOP_ATTR_DESCRIPTION);
-       ot->description= (item && PyUnicode_Check(item)) ? _PyUnicode_AsString(item):"";
-       Py_DECREF(item);
+       ot->description= (item && PyUnicode_Check(item)) ? _PyUnicode_AsString(item):"undocumented python operator";
+       Py_XDECREF(item);
        
        /* api callbacks, detailed checks dont on adding */ 
        if (PyObject_HasAttrString(py_class, "invoke"))
@@ -299,7 +295,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
                        PyObject *py_func_ptr, *py_kw, *py_srna_cobject, *py_ret;
                        item = PyList_GET_ITEM(props, i);
                        
-                       if (PyArg_ParseTuple(item, "O!O!", &PyCObject_Type, &py_func_ptr, &PyDict_Type, &py_kw)) {
+                       if (PyArg_ParseTuple(item, "O!O!:PYTHON_OT_wrapper", &PyCObject_Type, &py_func_ptr, &PyDict_Type, &py_kw)) {
                                
                                PyObject *(*pyfunc)(PyObject *, PyObject *, PyObject *);
                                pyfunc = PyCObject_AsVoidPtr(py_func_ptr);
@@ -309,6 +305,8 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
                                if (py_ret) {
                                        Py_DECREF(py_ret);
                                } else {
+                                       fprintf(stderr, "BPy Operator \"%s\" registration error: %s item %d could not run\n", ot->idname, PYOP_ATTR_PROP, i);
+                                       PyLineSpit();
                                        PyErr_Print();
                                        PyErr_Clear();
                                }