RNA: add check for zero step arguments

Avoids errors like T70281 slipping through.
This commit is contained in:
Campbell Barton 2019-10-01 20:30:04 +10:00
parent ba798e0412
commit c9b9803a77
4 changed files with 9 additions and 4 deletions

View File

@ -1718,7 +1718,7 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_funcs(prop, NULL, "rna_Brush_set_unprojected_radius", NULL);
RNA_def_property_range(prop, 0.001, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001, 1, 0, -1);
RNA_def_property_ui_range(prop, 0.001, 1, 1, -1);
RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
RNA_def_property_update(prop, 0, "rna_Brush_size_update");

View File

@ -1688,6 +1688,11 @@ void RNA_def_property_ui_range(
DefRNA.error = 1;
}
if (step == 0) {
CLOG_ERROR(&LOG, "\"%s.%s\", step is zero.", srna->identifier, prop->identifier);
DefRNA.error = 1;
}
if (precision < -1 || precision > UI_PRECISION_FLOAT_MAX) {
CLOG_ERROR(&LOG, "\"%s.%s\", precision outside range.", srna->identifier, prop->identifier);
DefRNA.error = 1;

View File

@ -3363,7 +3363,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
prop, NULL, "rna_UnifiedPaintSettings_unprojected_radius_set", NULL);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_range(prop, 0.001, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001, 1, 0, -1);
RNA_def_property_ui_range(prop, 0.001, 1, 1, -1);
RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_radius_update");

View File

@ -648,7 +648,7 @@ static void rna_def_paint(BlenderRNA *brna)
prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "num_input_samples");
RNA_def_property_ui_range(prop, 1, PAINT_MAX_INPUT_SAMPLES, 0, -1);
RNA_def_property_ui_range(prop, 1, PAINT_MAX_INPUT_SAMPLES, 1, -1);
RNA_def_property_ui_text(
prop, "Input Samples", "Average multiple input samples together to smooth the brush stroke");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
@ -1023,7 +1023,7 @@ static void rna_def_image_paint(BlenderRNA *brna)
/* integers */
prop = RNA_def_property(srna, "seam_bleed", PROP_INT, PROP_PIXEL);
RNA_def_property_ui_range(prop, 0, 8, 0, -1);
RNA_def_property_ui_range(prop, 0, 8, 1, -1);
RNA_def_property_ui_text(
prop, "Bleed", "Extend paint beyond the faces UVs to reduce seams (in pixels, slower)");