svn merge ^/trunk/blender -r40395:40405

This commit is contained in:
2011-09-23 10:58:20 +00:00
23 changed files with 393 additions and 204 deletions

View File

@@ -371,7 +371,6 @@ static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
return PyLong_FromLong(BLF_load(filename));
}
#ifdef INTERNATIONAL
PyDoc_STRVAR(py_blf_gettext_doc,
".. function:: gettext(msgid)\n"
"\n"
@@ -384,6 +383,7 @@ PyDoc_STRVAR(py_blf_gettext_doc,
);
static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *value)
{
#ifdef INTERNATIONAL
if ((U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE)) {
const char *msgid= _PyUnicode_AsString(value);
if(msgid == NULL) {
@@ -393,11 +393,12 @@ static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *value)
return PyUnicode_FromString(BLF_gettext(msgid));
}
else {
else
#endif /* INTERNATIONAL */
{
return Py_INCREF(value), value;
}
}
#endif /* INTERNATIONAL */
/*----------------------------MODULE INIT-------------------------*/
static PyMethodDef BLF_methods[] = {
@@ -414,9 +415,7 @@ static PyMethodDef BLF_methods[] = {
{"shadow_offset", (PyCFunction) py_blf_shadow_offset, METH_VARARGS, py_blf_shadow_offset_doc},
{"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc},
{"load", (PyCFunction) py_blf_load, METH_VARARGS, py_blf_load_doc},
#ifdef INTERNATIONAL
{"gettext", (PyCFunction) py_blf_gettext, METH_O, py_blf_gettext_doc},
#endif
{NULL, NULL, 0, NULL}
};

View File

@@ -30,4 +30,5 @@ void BPy_init_modules(void);
extern PyObject *bpy_package_py;
/* bpy_interface_atexit.c */
void BPY_atexit_init(void);
void BPY_atexit_register(void);
void BPY_atexit_unregister(void);

View File

@@ -241,7 +241,7 @@ void BPY_python_start(int argc, const char **argv)
pyrna_alloc_types();
BPY_atexit_init(); /* this can init any time */
BPY_atexit_register(); /* this can init any time */
#ifndef WITH_PYTHON_MODULE
py_tstate= PyGILState_GetThisThreadState();
@@ -262,6 +262,8 @@ void BPY_python_end(void)
bpy_intern_string_exit();
BPY_atexit_unregister(); /* without this we get recursive calls to WM_exit */
Py_Finalize();
#ifdef TIME_PY_RUN

View File

@@ -1,5 +1,5 @@
/*
* $Id:
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -46,24 +46,26 @@ static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyOb
}
static PyMethodDef meth_bpy_atexit= {"bpy_atexit", (PyCFunction)bpy_atexit, METH_NOARGS, NULL};
static PyObject *func_bpy_atregister= NULL; /* borrowed referebce, atexit holds */
void BPY_atexit_init(void)
static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
{
/* note - no error checking, if any of these fail we'll get a crash
* this is intended, but if its problematic it could be changed
* - campbell */
PyObject *atexit_mod= PyImport_ImportModuleLevel((char *)"atexit", NULL, NULL, NULL, 0);
PyObject *atexit_register= PyObject_GetAttrString(atexit_mod, "register");
PyObject *atexit_func= PyObject_GetAttrString(atexit_mod, func_name);
PyObject *args= PyTuple_New(1);
PyObject *ret;
PyTuple_SET_ITEM(args, 0, (PyObject *)PyCFunction_New(&meth_bpy_atexit, NULL));
PyTuple_SET_ITEM(args, 0, atexit_func_arg);
Py_INCREF(atexit_func_arg); /* only incref so we dont dec'ref along with 'args' */
ret= PyObject_CallObject(atexit_register, args);
ret= PyObject_CallObject(atexit_func, args);
Py_DECREF(atexit_mod);
Py_DECREF(atexit_register);
Py_DECREF(atexit_func);
Py_DECREF(args);
if(ret) {
@@ -72,5 +74,19 @@ void BPY_atexit_init(void)
else { /* should never happen */
PyErr_Print();
}
}
void BPY_atexit_register(void)
{
/* atexit module owns this new function reference */
BLI_assert(func_bpy_atregister ==NULL);
func_bpy_atregister= (PyObject *)PyCFunction_New(&meth_bpy_atexit, NULL);
atexit_func_call("register", func_bpy_atregister);
}
void BPY_atexit_unregister(void)
{
atexit_func_call("unregister", func_bpy_atregister);
func_bpy_atregister= NULL; /* don't really need to set but just incase */
}