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.
This commit is contained in:
Campbell Barton 2009-11-22 21:51:12 +00:00
parent 9c602bd455
commit dc5b0c8b9c
2 changed files with 18 additions and 11 deletions

@ -221,7 +221,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel):
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 @@ class PARTICLE_PT_physics(ParticleButtonsPanel):
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 @@ class PARTICLE_PT_physics(ParticleButtonsPanel):
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")

@ -591,9 +591,16 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v
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 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v
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 @@ static int pyrna_py_to_prop_index(BPy_PropertyRNA *self, int index, PyObject *va
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 {