From eb06ccc32462beaacbb114d6d0e450b6fc911047 Mon Sep 17 00:00:00 2001 From: Falk David Date: Mon, 19 Apr 2021 12:19:42 +0200 Subject: [PATCH] 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 --- source/blender/editors/interface/interface_handlers.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a5a5a69728e..c64e562c36c 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -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);