add checks for bad args to RNA_def_property_ui_range & RNA_def_property_range and fix one instance where (min > max).
also remove redundant float/double conversion in ui_get_but_step_unit()
This commit is contained in:
parent
42a619c781
commit
29d348f8de
|
@ -1807,12 +1807,14 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
|
|||
static float ui_get_but_step_unit(uiBut *but, float step_default)
|
||||
{
|
||||
int unit_type = RNA_SUBTYPE_UNIT_VALUE(uiButGetUnitType(but));
|
||||
float step;
|
||||
double step;
|
||||
|
||||
step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), but->block->unit->system, unit_type);
|
||||
|
||||
if (step > 0.0f) { /* -1 is an error value */
|
||||
return (float)((double)step / ui_get_but_scale_unit(but, 1.0)) * 100.0f;
|
||||
/* -1 is an error value */
|
||||
if (step != -1.0) {
|
||||
BLI_assert(step > 0.0);
|
||||
return (float)(step / ui_get_but_scale_unit(but, 1.0)) * 100.0f;
|
||||
}
|
||||
else {
|
||||
return step_default;
|
||||
|
|
|
@ -1321,6 +1321,26 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
|
|||
{
|
||||
StructRNA *srna = DefRNA.laststruct;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (min > max) {
|
||||
fprintf(stderr, "%s: \"%s.%s\", min > max.\n",
|
||||
__func__, srna->identifier, prop->identifier);
|
||||
DefRNA.error = 1;
|
||||
}
|
||||
|
||||
if (step < 0 || step > 100) {
|
||||
fprintf(stderr, "%s: \"%s.%s\", step outside range.\n",
|
||||
__func__, srna->identifier, prop->identifier);
|
||||
DefRNA.error = 1;
|
||||
}
|
||||
|
||||
if (precision < -1 || precision > 10) {
|
||||
fprintf(stderr, "%s: \"%s.%s\", step outside range.\n",
|
||||
__func__, srna->identifier, prop->identifier);
|
||||
DefRNA.error = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (prop->type) {
|
||||
case PROP_INT:
|
||||
{
|
||||
|
@ -1366,6 +1386,14 @@ void RNA_def_property_range(PropertyRNA *prop, double min, double max)
|
|||
{
|
||||
StructRNA *srna = DefRNA.laststruct;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (min > max) {
|
||||
fprintf(stderr, "%s: \"%s.%s\", min > max.\n",
|
||||
__func__, srna->identifier, prop->identifier);
|
||||
DefRNA.error = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (prop->type) {
|
||||
case PROP_INT:
|
||||
{
|
||||
|
|
|
@ -2781,7 +2781,7 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_ui_range(prop, 0, -M_PI * 2, M_PI * 2, 2);
|
||||
RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 2, -1);
|
||||
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
|
||||
RNA_def_property_ui_text(prop, "Angle", "Angle of revolution");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
|
Loading…
Reference in New Issue