diff options
Diffstat (limited to 'source/blender/editors/util/numinput.c')
-rw-r--r-- | source/blender/editors/util/numinput.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index d2bc8bc80c0..e07831358d6 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -477,6 +477,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) /* At this point, our value has changed, try to interpret it with python (if str is not empty!). */ if (n->str[0]) { + const float val_prev = n->val[idx]; #ifdef WITH_PYTHON Scene *sce = CTX_data_scene(C); double val; @@ -496,7 +497,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) n->unit_sys, n->unit_type[idx]); /* Note: with angles, we always get values as radians here... */ - if (BPY_button_exec(C, str_unit_convert, &val, false) != -1) { + if (BPY_execute_string_as_number(C, str_unit_convert, &val, false)) { n->val[idx] = (float)val; n->val_flag[idx] &= ~NUM_INVALID; } @@ -514,6 +515,11 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) if (n->val_flag[idx] & NUM_INVERSE) { n->val[idx] = 1.0f / n->val[idx]; } + + if (UNLIKELY(!isfinite(n->val[idx]))) { + n->val[idx] = val_prev; + n->val_flag[idx] |= NUM_INVALID; + } } /* REDRAW SINCE NUMBERS HAVE CHANGED */ |