diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-03 23:56:19 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-03 23:56:19 +0400 |
commit | 36df48eef63e4bc629ffae6f9b7c300ba2fdb35d (patch) | |
tree | 26777253d4b4af4dc32182a9e12f983ca34913d9 /source/blender/python | |
parent | 83c0fd65faa69491454c1eabd87bcf4c2c4b1237 (diff) |
2.5:
* Fix crash in python with enum properties, and don't throw
error if no matching identifier is found. This shouldn't
happen, but it should break a python script either, which
is not at fault.
* Fix a wrong variable initialization in fluidsim.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4729620bb8a..eff34b895da 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -307,8 +307,18 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) if (RNA_property_enum_identifier(ptr, prop, val, &identifier)) { ret = PyUnicode_FromString( identifier ); } else { - PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val); - ret = NULL; + const EnumPropertyItem *item; + + /* don't throw error here, can't trust blender 100% to give the + * right values, python code should not generate error for that */ + RNA_property_enum_items(ptr, prop, &item, NULL); + if(item[0].identifier) + ret = PyUnicode_FromString( item[0].identifier ); + else + ret = PyUnicode_FromString( "" ); + + /*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val); + ret = NULL;*/ } break; @@ -1745,8 +1755,18 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) if (RNA_property_enum_identifier(ptr, prop, val, &identifier)) { ret = PyUnicode_FromString( identifier ); } else { - PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val); - ret = NULL; + const EnumPropertyItem *item; + + /* don't throw error here, can't trust blender 100% to give the + * right values, python code should not generate error for that */ + RNA_property_enum_items(ptr, prop, &item, NULL); + if(item[0].identifier) + ret = PyUnicode_FromString( item[0].identifier ); + else + ret = PyUnicode_FromString( "" ); + + /*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val); + ret = NULL;*/ } break; |