diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-14 14:38:11 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-14 14:38:11 +0400 |
commit | 4a19ccfa5fb5cae359269ecaac389f6aace9f959 (patch) | |
tree | 78aa22e116cf7aed6d10d851978a5bdcf807fa84 /source/blender/python | |
parent | 5f02b167d191969474c8f3575abdd6dbaeffeb57 (diff) | |
parent | 9a79bd38ade00fc663c27ffda9892629ef5ca755 (diff) |
Merged changes in the trunk up to revision 45619.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/SConscript | 3 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types_select.c | 2 | ||||
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 3 | ||||
-rw-r--r-- | source/blender/python/generic/idprop_py_api.h | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 7 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 50 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils.c | 4 |
7 files changed, 48 insertions, 25 deletions
diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index a755c916ef3..dad1949bcf4 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -56,6 +56,9 @@ if env['WITH_BF_CYCLES']: if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') incs += ' ' + env['BF_FFMPEG_INC'] + +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs += ' ' + env['BF_PTHREADS_INC'] sources = env.Glob('intern/*.c') env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [361]) diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c index 4f3501944b0..c76c7d975e4 100644 --- a/source/blender/python/bmesh/bmesh_py_types_select.c +++ b/source/blender/python/bmesh/bmesh_py_types_select.c @@ -422,7 +422,7 @@ void BPy_BM_init_types_select(void) /* utility function */ /** - * \note doesnt actually check selection. + * \note doesn't actually check selection. */ int BPy_BMEditSel_Assign(BPy_BMesh *self, PyObject *value) { diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 63b8d90b510..cd2b1fb148e 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -134,7 +134,8 @@ static Py_hash_t BPy_IDGroup_hash(BPy_IDProperty *self) static PyObject *BPy_IDGroup_repr(BPy_IDProperty *self) { - return PyUnicode_FromFormat("<bpy id property from \"%s\">", self->id->name); + return PyUnicode_FromFormat("<bpy id prop: owner=\"%s\", name=\"%s\", address=%p>", + self->id ? self->id->name : "<NONE>", self->prop->name, self->prop); } PyObject *BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent) diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h index f053f212a23..35b130d005e 100644 --- a/source/blender/python/generic/idprop_py_api.h +++ b/source/blender/python/generic/idprop_py_api.h @@ -34,7 +34,7 @@ struct BPy_IDGroup_Iter; typedef struct BPy_IDProperty { PyObject_VAR_HEAD - struct ID *id; + struct ID *id; /* can be NULL */ struct IDProperty *prop; /* must be second member */ struct IDProperty *parent; PyObject *data_wrap; @@ -42,7 +42,7 @@ typedef struct BPy_IDProperty { typedef struct BPy_IDArray { PyObject_VAR_HEAD - struct ID *id; + struct ID *id; /* can be NULL */ struct IDProperty *prop; /* must be second member */ } BPy_IDArray; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 7b362e56c73..f68ef6838e8 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -57,6 +57,7 @@ #include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" +#include "BLI_threads.h" #include "BKE_context.h" #include "BKE_text.h" @@ -95,6 +96,12 @@ static double bpy_timer_run_tot; /* accumulate python runs */ /* use for updating while a python script runs - in case of file load */ void bpy_context_update(bContext *C) { + /* don't do this from a non-main (e.g. render) thread, it can cause a race + condition on C->data.recursion. ideal solution would be to disable + context entirely from non-main threads, but that's more complicated */ + if(!BLI_thread_is_main()) + return; + BPy_SetContext(C); bpy_import_main_set(CTX_data_main(C)); BPY_modules_update(C); /* can give really bad results if this isn't here */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 53f9e46ba13..7259ea8e2f5 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -871,10 +871,17 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self) const char *path; path = RNA_path_from_ID_to_struct(&self->ptr); if (path) { - ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", - BKE_idcode_to_name_plural(GS(id->name)), - tmp_str, - path); + if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ + ret = PyUnicode_FromFormat("bpy.data...%s", + path); + } + else { + ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", + BKE_idcode_to_name_plural(GS(id->name)), + tmp_str, + path); + } + MEM_freeN((void *)path); } else { /* cant find, print something sane */ @@ -971,10 +978,17 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) path = RNA_path_from_ID_to_property(&self->ptr, self->prop); if (path) { - ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", - BKE_idcode_to_name_plural(GS(id->name)), - tmp_str, - path); + if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ + ret = PyUnicode_FromFormat("bpy.data...%s", + path); + } + else { + ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", + BKE_idcode_to_name_plural(GS(id->name)), + tmp_str, + path); + } + MEM_freeN((void *)path); } else { /* cant find, print something sane */ @@ -1138,10 +1152,6 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr return -1; } else { - /* hack so that dynamic enums used for operator properties will be able to be built (i.e. context will be supplied to itemf) - * and thus running defining operator buttons for such operators in UI will work */ - RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); - if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, val)) { const char *enum_str = pyrna_enum_as_string(ptr, prop); PyErr_Format(PyExc_TypeError, @@ -2433,7 +2443,7 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val if (RNA_property_flag(self->prop) & PROP_NEVER_NULL) { PyErr_Format(PyExc_TypeError, "bpy_prop_collection[key] = value: invalid, " - "this collection doesnt support None assignment"); + "this collection doesn't support None assignment"); return -1; } else { @@ -3310,13 +3320,15 @@ static void pyrna_dir_members_py(PyObject *list, PyObject *self) /* since this is least common case, handle it last */ if (BPy_PropertyRNA_Check(self)) { BPy_PropertyRNA *self_prop = (BPy_PropertyRNA *)self; - PointerRNA r_ptr; + if (RNA_property_type(self_prop->prop) == PROP_COLLECTION) { + PointerRNA r_ptr; - if (RNA_property_collection_type_get(&self_prop->ptr, self_prop->prop, &r_ptr)) { - PyObject *cls = pyrna_struct_Subtype(&r_ptr); /* borrows */ - dict = ((PyTypeObject *)cls)->tp_dict; - pyrna_dir_members_py__add_keys(list, dict); - Py_DECREF(cls); + if (RNA_property_collection_type_get(&self_prop->ptr, self_prop->prop, &r_ptr)) { + PyObject *cls = pyrna_struct_Subtype(&r_ptr); /* borrows */ + dict = ((PyTypeObject *)cls)->tp_dict; + pyrna_dir_members_py__add_keys(list, dict); + Py_DECREF(cls); + } } } } diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 5f9e68f07d8..5ae58973602 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -292,7 +292,7 @@ int mathutils_deepcopy_args_check(PyObject *args) /* Mathutils Callbacks */ /* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */ -#define MATHUTILS_TOT_CB 8 +#define MATHUTILS_TOT_CB 10 static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL}; unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb) @@ -305,7 +305,7 @@ unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb) return i; } - BLI_assert(i < MATHUTILS_TOT_CB); + BLI_assert(i + 1 < MATHUTILS_TOT_CB); mathutils_callbacks[i] = cb; return i; |