[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24787] trunk/blender: rna functions were getting away with passing the string "True" instead of True, changed get the integer value and test its 1 or 0.
Campbell Barton
ideasman42 at gmail.com
Sun Nov 22 22:51:13 CET 2009
Revision: 24787
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24787
Author: campbellbarton
Date: 2009-11-22 22:51:12 +0100 (Sun, 22 Nov 2009)
Log Message:
-----------
rna functions were getting away with passing the string "True" instead of True, changed get the integer value and test its 1 or 0.
allow rna function return values as an exception since so many poll functions do... "return (context.blah and context.foo)", that makign all return bool's isnt that nice.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/properties_particle.py
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/release/scripts/ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_particle.py 2009-11-22 21:47:55 UTC (rev 24786)
+++ trunk/blender/release/scripts/ui/properties_particle.py 2009-11-22 21:51:12 UTC (rev 24787)
@@ -221,7 +221,7 @@
sub.itemR(cloth, "pin_stiffness", text="Stiffness")
sub.itemR(cloth, "mass")
sub.itemR(cloth, "bending_stiffness", text="Bending")
- sub.itemR(cloth, "internal_friction", slider="True")
+ sub.itemR(cloth, "internal_friction", slider=True)
col = split.column()
@@ -410,9 +410,9 @@
col = sub.column(align=True)
col.active = boids.allow_flight
col.itemR(boids, "air_max_speed")
- col.itemR(boids, "air_min_speed", slider="True")
- col.itemR(boids, "air_max_acc", slider="True")
- col.itemR(boids, "air_max_ave", slider="True")
+ col.itemR(boids, "air_min_speed", slider=True)
+ col.itemR(boids, "air_max_acc", slider=True)
+ col.itemR(boids, "air_max_ave", slider=True)
col.itemR(boids, "air_personal_space")
row = col.row()
row.active = (boids.allow_land or boids.allow_climb) and boids.allow_flight
@@ -423,8 +423,8 @@
col.active = boids.allow_land or boids.allow_climb
col.itemR(boids, "land_max_speed")
col.itemR(boids, "land_jump_speed")
- col.itemR(boids, "land_max_acc", slider="True")
- col.itemR(boids, "land_max_ave", slider="True")
+ col.itemR(boids, "land_max_acc", slider=True)
+ col.itemR(boids, "land_max_ave", slider=True)
col.itemR(boids, "land_personal_space")
col.itemR(boids, "land_stick_force")
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2009-11-22 21:47:55 UTC (rev 24786)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2009-11-22 21:51:12 UTC (rev 24787)
@@ -591,9 +591,16 @@
switch (type) {
case PROP_BOOLEAN:
{
- int param = PyObject_IsTrue( value );
+ int param;
+ /* prefer not to have an exception here
+ * however so many poll functions return None or a valid Object.
+ * its a hassle to convert these into a bool before returning, */
+ if(RNA_property_flag(prop) & PROP_RETURN)
+ param = PyObject_IsTrue( value );
+ else
+ param = PyLong_AsSsize_t( value );
- if( param < 0 ) {
+ if( param < 0 || param > 1) {
PyErr_Format(PyExc_TypeError, "%.200s expected True/False or 0/1", error_prefix);
return -1;
} else {
@@ -681,7 +688,7 @@
PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptype));
return -1;
} else if((flag & PROP_NEVER_NULL) && value == Py_None) {
- PyErr_Format(PyExc_TypeError, "property can't be assigned a None value");
+ PyErr_Format(PyExc_TypeError, "%.200s does not suppory a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptype));
return -1;
} else {
BPy_StructRNA *param= (BPy_StructRNA*)value;
@@ -813,9 +820,9 @@
switch (type) {
case PROP_BOOLEAN:
{
- int param = PyObject_IsTrue( value );
+ int param = PyLong_AsSsize_t( value );
- if( param < 0 ) {
+ if( param < 0 || param > 1) {
PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
ret = -1;
} else {
More information about the Bf-blender-cvs
mailing list