diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-05 16:55:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-05 16:55:51 +0300 |
commit | 01b762e8463ec6192d43b3bfac7d29b0c24757c0 (patch) | |
tree | 30bd513ca4673608c9239dafed262cafe4871cd4 /source/blender | |
parent | cc72f7e1b12779f215b75af890b45cfa5d78a5e8 (diff) |
fix for bpyob.foreach_set(), when the list is empty
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index cd607961788..58af86f077d 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2241,6 +2241,7 @@ static void foreach_attr_type( BPy_PropertyRNA *self, char *attr, *attr_tot= 0; *attr_signed= FALSE; + /* note: this is fail with zero length lists, so dont let this get caled in that case */ RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) { prop = RNA_struct_find_property(&itemptr, attr); *raw_type= RNA_property_raw_type(prop); @@ -2297,7 +2298,9 @@ static int foreach_parse_args( #endif } - if (*size == 0) { + /* check 'attr_tot' otherwise we dont know if any values were set + * this isnt ideal because it means running on an empty list may fail silently when its not compatible. */ + if (*size == 0 && *attr_tot != 0) { PyErr_SetString( PyExc_AttributeError, "attribute does not support foreach method" ); return -1; } |