Fix T87448: Avoid uiBut update if value was same

Previously, clicking into a number field, changing nothing and then
clicking outside the field again would trigger an update (RNA prop
would be set to the same value again). This could potentially cause
an expensive operation (like a modifer) to run again, even if all the
parameters were identical.

The fix prevents this by treating unchanging values in the field as a
cancel operation.

Reviewed By: Severin

Maniphest Tasks: T87448

Differential Revision: https://developer.blender.org/D10976
This commit is contained in:
Falk David 2021-04-19 12:19:42 +02:00
parent 799f532f46
commit eb06ccc324
Notes: blender-bot 2024-01-25 12:01:42 +01:00
Referenced by commit 3bf10e5d0a, Fix T89996, T90063: bugs with multi-button reset and entering values in popups
Referenced by commit e1a9ba94c5, Fix T87637: Dragging button value cancel not working
Referenced by issue #90514, Drag sliding multiple values doesn't work as expected
Referenced by issue #90063, Regression: Set curve radius does not work
Referenced by issue #89996, Resetting multi-button value does not work when active button value is the same
Referenced by issue #87688, Crash when current frame is used as driver
Referenced by issue #87637, Escaping editing a button does not reset change from dragging
Referenced by issue #87448, Blender re-evaluates modifiers unnecessarily when parameters are not changed
Referenced by pull request #115831, WIP: UI: dont run update functions if button values did not change
1 changed files with 6 additions and 0 deletions

View File

@ -1126,6 +1126,12 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
ui_but_value_set(but, data->value);
}
/* If the value entered is the exact same, do not trigger an update. */
if (data->value == data->startvalue) {
data->cancel = true;
return;
}
ui_but_update_edited(but);
ui_apply_but_func(C, but);