fix for crash drawing the UI, normally this would cause a memory leak but for some reason it crashed with py2.6 and not 3.1.

This commit is contained in:
2009-05-20 05:35:53 +00:00
parent 42b5e49589
commit a1cc5ef8eb

View File

@@ -1843,10 +1843,20 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
py_class= RNA_struct_py_type_get(ptr->type);
args = PyTuple_New(1);
PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(ptr));
py_class_instance = PyObject_Call(py_class, args, NULL);
Py_DECREF(args);
item = pyrna_struct_CreatePyObject(ptr);
if(item == NULL) {
py_class_instance = NULL;
}
else if(item == Py_None) { /* probably wont ever happen but possible */
Py_DECREF(item);
py_class_instance = NULL;
}
else {
args = PyTuple_New(1);
PyTuple_SET_ITEM(args, 0, item);
py_class_instance = PyObject_Call(py_class, args, NULL);
Py_DECREF(args);
}
if (py_class_instance) { /* Initializing the class worked, now run its invoke function */
item= PyObject_GetAttrString(py_class, RNA_function_identifier(func));
@@ -1877,8 +1887,8 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
ret = PyObject_Call(item, args, NULL);
/* args is decref'd from item */
Py_DECREF(item);
Py_DECREF(args);
}
else {
Py_DECREF(py_class_instance);