[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21358] branches/blender2.5/blender/source /blender: 2.5:
Brecht Van Lommel
brecht at blender.org
Fri Jul 3 21:56:19 CEST 2009
Revision: 21358
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21358
Author: blendix
Date: 2009-07-03 21:56:19 +0200 (Fri, 03 Jul 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/intern/fluidsim.c
branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fluidsim.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fluidsim.c 2009-07-03 19:12:59 UTC (rev 21357)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fluidsim.c 2009-07-03 19:56:19 UTC (rev 21358)
@@ -114,7 +114,7 @@
// no bounding box needed
// todo - reuse default init from elbeem!
- fss->typeFlags = 0;
+ fss->typeFlags = OB_FSBND_NOSLIP;
fss->domainNovecgen = 0;
fss->volumeInitType = 1; // volume
fss->partSlipValue = 0.0;
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-07-03 19:12:59 UTC (rev 21357)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-07-03 19:56:19 UTC (rev 21358)
@@ -1568,22 +1568,20 @@
int i, defaultfound= 0;
if(eprop->item) {
- fprintf(f, "static EnumPropertyItem rna_%s%s_%s_items[%d] = {", srna->identifier, strnest, prop->identifier, eprop->totitem);
+ fprintf(f, "static EnumPropertyItem rna_%s%s_%s_items[%d] = {", srna->identifier, strnest, prop->identifier, eprop->totitem+1);
for(i=0; i<eprop->totitem; i++) {
fprintf(f, "{%d, ", eprop->item[i].value);
rna_print_c_string(f, eprop->item[i].identifier); fprintf(f, ", ");
fprintf(f, "%d, ", eprop->item[i].icon);
rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", ");
- rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}");
- if(i != eprop->totitem-1)
- fprintf(f, ", ");
+ rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}, ");
if(eprop->defaultvalue == eprop->item[i].value)
defaultfound= 1;
}
- fprintf(f, "};\n\n");
+ fprintf(f, "{0, NULL, 0, NULL, NULL}};\n\n");
if(!defaultfound) {
fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default is not in items.\n", srna->identifier, errnest, prop->identifier);
Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c 2009-07-03 19:12:59 UTC (rev 21357)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c 2009-07-03 19:56:19 UTC (rev 21358)
@@ -307,8 +307,18 @@
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 @@
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;
More information about the Bf-blender-cvs
mailing list