[Bf-blender-cvs] [c9b9803a772] master: RNA: add check for zero step arguments

Campbell Barton noreply at git.blender.org
Tue Oct 1 12:31:54 CEST 2019


Commit: c9b9803a772ccb7539a71785e121b049620d00d7
Author: Campbell Barton
Date:   Tue Oct 1 20:30:04 2019 +1000
Branches: master
https://developer.blender.org/rBc9b9803a772ccb7539a71785e121b049620d00d7

RNA: add check for zero step arguments

Avoids errors like T70281 slipping through.

===================================================================

M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index aef15e6d30a..d7bb941b266 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -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");
 
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 758fbd07f85..fc22e9e6c74 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -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;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 4960dc82b28..1f967df7232 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -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");
 
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index eb411538b41..1457bbfd3c3 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -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)");



More information about the Bf-blender-cvs mailing list