Merged changes in the trunk up to revision 28911.

This commit is contained in:
2010-05-21 22:01:47 +00:00
178 changed files with 7473 additions and 8152 deletions

View File

@@ -46,6 +46,7 @@ static PyStructSequence_Field app_info_fields[] = {
{"home", "The blender home directory, normally matching $HOME"},
{"binary_path", "The location of blenders executable, useful for utilities that spawn new instances"},
{"debug", "Boolean, set when blender is running in debug mode (started with -d)"},
{"background", "Boolean, True when blender is running without a user interface (started with -b)"},
/* buildinfo */
{"build_date", "The date this blender instance was built"},
@@ -60,7 +61,7 @@ static PyStructSequence_Desc app_info_desc = {
"bpy.app", /* name */
"This module contains application values that remain unchanged during runtime.", /* doc */
app_info_fields, /* fields */
10
(sizeof(app_info_fields)/sizeof(PyStructSequence_Field)) - 1
};
static PyObject *make_app_info(void)
@@ -87,6 +88,7 @@ static PyObject *make_app_info(void)
SetStrItem(BLI_gethome());
SetStrItem(bprogname);
SetObjItem(PyBool_FromLong(G.f & G_DEBUG));
SetObjItem(PyBool_FromLong(G.background));
/* build info */
#ifdef BUILD_DATE

View File

@@ -109,7 +109,11 @@ static int bpy_pydriver_create_dict(void)
*/
void BPY_pydriver_update(void)
{
PyGILState_STATE gilstate = PyGILState_Ensure();
PyGILState_STATE gilstate;
int use_gil= 1; // (PyThreadState_Get()==NULL);
if(use_gil)
gilstate = PyGILState_Ensure();
if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
PyDict_Clear(bpy_pydriver_Dict);
@@ -117,7 +121,8 @@ void BPY_pydriver_update(void)
bpy_pydriver_Dict = NULL;
}
PyGILState_Release(gilstate);
if(use_gil)
PyGILState_Release(gilstate);
return;
}
@@ -143,6 +148,10 @@ static float pydriver_error(ChannelDriver *driver)
/* This evals py driver expressions, 'expr' is a Python expression that
* should evaluate to a float number, which is returned.
*
* note: PyGILState_Ensure() isnt always called because python can call the
* bake operator which intern starts a thread which calls scene update which
* does a driver update. to avoid a deadlock check PyThreadState_Get() if PyGILState_Ensure() is needed.
*/
float BPY_pydriver_eval (ChannelDriver *driver)
{
@@ -151,6 +160,7 @@ float BPY_pydriver_eval (ChannelDriver *driver)
PyObject *expr_vars; /* speed up by pre-hashing string & avoids re-converting unicode strings for every execution */
PyObject *expr_code;
PyGILState_STATE gilstate;
int use_gil;
DriverVar *dvar;
double result = 0.0; /* default return */
@@ -168,13 +178,17 @@ float BPY_pydriver_eval (ChannelDriver *driver)
return 0.0f;
}
gilstate = PyGILState_Ensure();
use_gil= 1; //(PyThreadState_Get()==NULL);
if(use_gil)
gilstate = PyGILState_Ensure();
/* init global dictionary for py-driver evaluation settings */
if (!bpy_pydriver_Dict) {
if (bpy_pydriver_create_dict() != 0) {
fprintf(stderr, "Pydriver error: couldn't create Python dictionary");
PyGILState_Release(gilstate);
if(use_gil)
PyGILState_Release(gilstate);
return 0.0f;
}
}
@@ -269,7 +283,8 @@ float BPY_pydriver_eval (ChannelDriver *driver)
Py_DECREF(retval);
}
PyGILState_Release(gilstate);
if(use_gil)
PyGILState_Release(gilstate);
if(finite(result)) {
return (float)result;

View File

@@ -1194,17 +1194,17 @@ static Py_ssize_t pyrna_prop_collection_length( BPy_PropertyRNA *self )
static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum)
{
PointerRNA newptr;
int len= RNA_property_collection_length(&self->ptr, self->prop);
int len= RNA_property_collection_length(&self->ptr, self->prop);
if(keynum < 0) keynum += len;
if(keynum >= 0 && keynum < len) {
if(RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
}
PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d could not be found", keynum);
return NULL;
}
if(keynum >= 0 && keynum < len) {
if(RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
}
PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d could not be found", keynum);
return NULL;
}
PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d out of range", keynum);
return NULL;
}
@@ -1637,6 +1637,8 @@ static PySequenceMethods pyrna_prop_array_as_sequence = {
(ssizeobjargproc)prop_subscript_ass_array_int, /* sq_ass_item */
NULL, /* *was* sq_ass_slice */
(objobjproc)pyrna_prop_array_contains, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PySequenceMethods pyrna_prop_collection_as_sequence = {
@@ -1648,6 +1650,8 @@ static PySequenceMethods pyrna_prop_collection_as_sequence = {
NULL, /* sq_ass_item */
NULL, /* *was* sq_ass_slice */
(objobjproc)pyrna_prop_collection_contains, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PySequenceMethods pyrna_struct_as_sequence = {
@@ -1659,6 +1663,8 @@ static PySequenceMethods pyrna_struct_as_sequence = {
NULL, /* sq_ass_item */
NULL, /* *was* sq_ass_slice */
(objobjproc)pyrna_struct_contains, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PyObject *pyrna_struct_subscript( BPy_StructRNA *self, PyObject *key )
@@ -1886,7 +1892,7 @@ static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *arg
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
char *group_name= NULL;
char *group_name= NULL;
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1)
return NULL;
@@ -1920,7 +1926,7 @@ static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *arg
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
char *group_name= NULL;
char *group_name= NULL;
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_delete()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1)
return NULL;
@@ -3550,7 +3556,7 @@ PyTypeObject pyrna_prop_Type = {
0, /* tp_itemsize */
/* methods */
NULL, /* tp_dealloc */
NULL, /* printfunc tp_print; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */