[Bf-blender-cvs] [eb06ccc3246] master: Fix T87448: Avoid uiBut update if value was same

Falk David noreply at git.blender.org
Mon Apr 19 12:20:41 CEST 2021


Commit: eb06ccc32462beaacbb114d6d0e450b6fc911047
Author: Falk David
Date:   Mon Apr 19 12:19:42 2021 +0200
Branches: master
https://developer.blender.org/rBeb06ccc32462beaacbb114d6d0e450b6fc911047

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

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

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

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

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);



More information about the Bf-blender-cvs mailing list