Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-09-23 06:12:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-23 06:12:33 +0400
commit2b9a73ff9831aed988bde26ca1fce474ace01cf6 (patch)
tree84d5655dd61c632e61df874f95229f9945ceab4d /source/blender
parentdb47803de42a5b1ae4e6cd381fa5908b33f96721 (diff)
- py/rna's path_resolve function was ignoring the index eg: obj.path_resolve("location[1]")
- corrected comment from previous commit
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/armature.c4
-rw-r--r--source/blender/python/intern/bpy_array.c6
-rw-r--r--source/blender/python/intern/bpy_rna.c20
-rw-r--r--source/blender/python/intern/bpy_rna.h1
4 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index bfd12f7cc5d..2e760f53155 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1289,8 +1289,8 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
/* Find Axis & Amount for bone matrix*/
cross_v3_v3v3(axis,target,nor);
- /* was 0.0000000000001, caused bug [#23954], larger values give unstable
- * when toggling editmode */
+ /* was 0.0000000000001, caused bug [#23954], smaller values give unstable
+ * roll when toggling editmode */
if (dot_v3v3(axis,axis) > 0.00001) {
/* if nor is *not* a multiple of target ... */
normalize_v3(axis);
diff --git a/source/blender/python/intern/bpy_array.c b/source/blender/python/intern/bpy_array.c
index 1afd54b3607..6d971d8708e 100644
--- a/source/blender/python/intern/bpy_array.c
+++ b/source/blender/python/intern/bpy_array.c
@@ -400,7 +400,7 @@ int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, in
return ret;
}
-static PyObject *pyrna_array_item(PointerRNA *ptr, PropertyRNA *prop, int index)
+PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
PyObject *item;
@@ -441,7 +441,7 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
if (dim + 1 < totdim)
item= pyrna_py_from_array_internal(ptr, prop, dim + 1, index);
else {
- item= pyrna_array_item(ptr, prop, *index);
+ item= pyrna_array_index(ptr, prop, *index);
*index= *index + 1;
}
@@ -496,7 +496,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
}
else {
index = arrayoffset + index;
- ret= (BPy_PropertyArrayRNA *)pyrna_array_item(ptr, prop, index);
+ ret= (BPy_PropertyArrayRNA *)pyrna_array_index(ptr, prop, index);
}
return (PyObject*)ret;
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index d2234963927..418bece5e7b 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2262,17 +2262,29 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
PyObject *coerce= Py_True;
PointerRNA r_ptr;
PropertyRNA *r_prop;
+ int index= -1;
if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce))
return NULL;
- if (RNA_path_resolve(&self->ptr, path, &r_ptr, &r_prop)) {
+ if (RNA_path_resolve_full(&self->ptr, path, &r_ptr, &r_prop, &index)) {
if(r_prop) {
- if(coerce == Py_False) {
- return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
+ if(index != -1) {
+ if(index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) {
+ PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") index out of range", RNA_struct_identifier(self->ptr.type), path);
+ return NULL;
+ }
+ else {
+ return pyrna_array_index(&r_ptr, r_prop, index);
+ }
}
else {
- return pyrna_prop_to_py(&r_ptr, r_prop);
+ if(coerce == Py_False) {
+ return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
+ }
+ else {
+ return pyrna_prop_to_py(&r_ptr, r_prop);
+ }
}
}
else {
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 4b8beb42930..7f750f94242 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -101,6 +101,7 @@ void pyrna_free_types(void);
/* primitive type conversion */
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, PyObject *py, const char *error_prefix);
int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix);
+PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index);
PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop);
PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index);