diff options
author | Hans Goudey <h.goudey@me.com> | 2021-01-27 20:22:55 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-01-27 20:22:55 +0300 |
commit | 4c4ccdfa3663695950f409ed6a07c446b9f56093 (patch) | |
tree | 30ed8bb4358daeb2896db14074c089f403c70ebc /source/blender/makesrna/intern | |
parent | c71a8e837616159735a925bbb82c868646e7d3a1 (diff) |
RNA: Add warning to float percentage property definition
As a followup to rBc71a8e837616159735, add a debug-only check for
incorrect range, when the percentage and factor functions were likely
confused.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index cec6a50d170..da04ac63ee3 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -4111,6 +4111,16 @@ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_, ASSERT_SOFT_HARD_LIMITS; +#ifdef DEBUG + /* Properties with PROP_PERCENTAGE should use a range like 0 to 100, unlike PROP_FACTOR. */ + if (hardmax < 2.0f) { + CLOG_WARN(&LOG, + "Percentage property with incorrect range: %s.%s", + CONTAINER_RNA_ID(cont), + identifier); + } +#endif + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_default(prop, default_value); if (hardmin != hardmax) { |