checks in rna range functions that the max value cant be less than the min.

also fix for invalid rage for FILE_OT_filenum.
This commit is contained in:
Campbell Barton
2011-06-23 06:13:21 +00:00
parent 353cd44301
commit 53bf66a579
7 changed files with 18 additions and 5 deletions

View File

@@ -1279,7 +1279,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot)
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
/* props */
RNA_def_int(ot->srna, "increment", 1, 0, 100, "Increment", "", 0,100);
RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100,100);
}
static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))

View File

@@ -1603,6 +1603,8 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
IDProperty *idprop;
BLI_assert(RNA_property_type(prop) == PROP_INT);
/* useful to check on bad values but set function should clamp */
/* BLI_assert(RNA_property_int_clamp(ptr, prop, &value) == 0); */
if((idprop=rna_idproperty_check(&prop, ptr)))
IDP_Int(idprop)= value;
@@ -1825,6 +1827,8 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
IDProperty *idprop;
BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
/* useful to check on bad values but set function should clamp */
/* BLI_assert(RNA_property_float_clamp(ptr, prop, &value) == 0); */
if((idprop=rna_idproperty_check(&prop, ptr))) {
if(idprop->type == IDP_FLOAT)

View File

@@ -233,6 +233,7 @@ static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max)
Curve *cu= (Curve*)ptr->id.data;
*min= 0;
*max= cu->totcol-1;
*max= MAX2(0, *max);
}
static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max)
@@ -240,6 +241,7 @@ static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int
Curve *cu= (Curve*)ptr->id.data;
*min= 0;
*max= cu->totbox-1;
*max= MAX2(0, *max);
}

View File

@@ -305,6 +305,7 @@ static void rna_MeshFace_material_index_range(PointerRNA *ptr, int *min, int *ma
Mesh *me= (Mesh*)ptr->id.data;
*min= 0;
*max= me->totcol-1;
*max= MAX2(0, *max);
}
static CustomData *rna_mesh_fdata(Mesh *me)

View File

@@ -404,7 +404,8 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max
MultiresModifierData *mmd = (MultiresModifierData*)ptr->data;
*min = 0;
*max = mmd->totlvl;
*max = mmd->totlvl; /* intentionally _not_ -1 */
*max= MAX2(0, *max);
}
static int rna_MultiresModifier_external_get(PointerRNA *ptr)

View File

@@ -1024,8 +1024,13 @@ static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, i
Key *key= ob_get_key(ob);
*min= 0;
*max= (key)? BLI_countlist(&key->block)-1: 0;
*max= MAX2(0, *max);
if(key) {
*max= BLI_countlist(&key->block)-1;
if(*max < 0) *max= 0;
}
else {
*max= 0;
}
}
static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)

View File

@@ -700,7 +700,7 @@ static void rna_ConsoleLine_cursor_index_range(PointerRNA *ptr, int *min, int *m
ConsoleLine *ci= (ConsoleLine*)ptr->data;
*min= 0;
*max= ci->len;
*max= ci->len; /* intentionally _not_ -1 */
}
/* Space Dopesheet */