fix for leak in gpu.export_shader(), wasnt freeing the function.

also change the bmesh iterator so its possible to initialize without stepping.
This commit is contained in:
2012-02-20 22:04:29 +00:00
parent d31e1533a3
commit c4e7cc3287
7 changed files with 83 additions and 59 deletions

View File

@@ -646,3 +646,39 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
PyGILState_Release(gilstate);
}
}
/* generic function to avoid depending on RNA */
void *PyC_RNA_AsPointer(PyObject *value, const char *type_name)
{
PyObject* as_pointer;
PyObject* pointer;
if (!strcmp(Py_TYPE(value)->tp_name, type_name) &&
(as_pointer = PyObject_GetAttrString(value, "as_pointer")) != NULL &&
PyCallable_Check(as_pointer))
{
void *result = NULL;
/* must be a 'type_name' object */
pointer = PyObject_CallObject(as_pointer, NULL);
Py_DECREF(as_pointer);
if (!pointer) {
PyErr_SetString(PyExc_SystemError, "value.as_pointer() failed");
return NULL;
}
result = PyLong_AsVoidPtr(pointer);
Py_DECREF(pointer);
if (!result) {
PyErr_SetString(PyExc_SystemError, "value.as_pointer() failed");
}
return result;
}
else {
PyErr_Format(PyExc_TypeError,
"expected '%.200s' type found '%.200s' instead",
type_name, Py_TYPE(value)->tp_name);
return NULL;
}
}

View File

@@ -54,4 +54,6 @@ void PyC_SetHomePath(const char *py_path_bundle);
#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL)
void *PyC_RNA_AsPointer(PyObject *value, const char *type_name);
#endif // __PY_CAPI_UTILS_H__