Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFalk David <falkdavid@gmx.de>2021-04-22 20:01:37 +0300
committerFalk David <falkdavid@gmx.de>2021-04-22 20:02:48 +0300
commitbbb52a462ef91c9f84f673102b851a897b5968ac (patch)
treec546a376a2a702ade53b41af18b3f738f673dbf7
parentd1ccc5b9694b7c737158f4d4bd83ae780b32d258 (diff)
Fix T87688: Crash entering valid text into number field
When the user entered a driver expression like `#frame` into a number field, Blender would crash sometime after. This is because e1a9ba94c599 did not handle this case properly and ignored the fact that the user can enter text into the field. The fix makes sure that we only cancel if the value is a *number* equal to the previous value in the field. Note that this could also be handled by `ui_but_string_set` which would be a bit nicer potentially. However, I was unable to find a clean way of passing `data->startvalue` into that function. `uiHandleButtonData` is only known locally inside `interface_handlers.c`. Reviewed By: Severin Maniphest Tasks: T87688 Differential Revision: https://developer.blender.org/D11049
-rw-r--r--source/blender/editors/interface/interface_handlers.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 4cbf5fca49a..4931b35ca75 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1114,6 +1114,13 @@ static void ui_apply_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data)
static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (data->str) {
+ double value;
+ /* Check if the string value is a number and cancel if it's equal to the startvalue. */
+ if (ui_but_string_eval_number(C, but, data->str, &value) && (value == data->startvalue)) {
+ data->cancel = true;
+ return;
+ }
+
if (ui_but_string_set(C, but, data->str)) {
data->value = ui_but_value_get(but);
}
@@ -1121,12 +1128,6 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
data->cancel = true;
return;
}
-
- /* If the value entered is the exact same, do not trigger an update. */
- if (data->value == data->startvalue) {
- data->cancel = true;
- return;
- }
}
else {
ui_but_value_set(but, data->value);