[Bf-blender-cvs] [30d900934c4] master: UI: assert on invalid click-step for integer buttons

Campbell Barton noreply at git.blender.org
Fri Aug 30 15:44:46 CEST 2019


Commit: 30d900934c4b06c13c65bbf1c9ef34fa14b2c256
Author: Campbell Barton
Date:   Fri Aug 30 23:40:14 2019 +1000
Branches: master
https://developer.blender.org/rB30d900934c4b06c13c65bbf1c9ef34fa14b2c256

UI: assert on invalid click-step for integer buttons

Avoids T69305 going by unnoticed.

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

M	source/blender/editors/interface/interface.c

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 66c8eadbd74..0855412bcc4 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3586,6 +3586,14 @@ static uiBut *ui_def_but(uiBlock *block,
                 (a1 != 0.0f && a1 != 1.0f)) == false);
   }
 
+  /* Number buttons must have a click-step,
+   * assert instead of correcting the value to ensure the caller knowns what they're doing.  */
+  if ((type & BUTTYPE) == UI_BTYPE_NUM) {
+    if (ELEM((type & UI_BUT_POIN_TYPES), UI_BUT_POIN_CHAR, UI_BUT_POIN_SHORT, UI_BUT_POIN_INT)) {
+      BLI_assert((int)a1 > 0);
+    }
+  }
+
   if (type & UI_BUT_POIN_TYPES) { /* a pointer is required */
     if (poin == NULL) {
       BLI_assert(0);



More information about the Bf-blender-cvs mailing list