[Bf-blender-cvs] [82ba2056462] blender-v3.4-release: Fix T85870: ColorRamp Keyframes crash Blender

Julian Eisel noreply at git.blender.org
Tue Nov 8 12:18:01 CET 2022


Commit: 82ba2056462310b103ad16fba726340886e5b0b7
Author: Julian Eisel
Date:   Tue Nov 8 12:14:31 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB82ba2056462310b103ad16fba726340886e5b0b7

Fix T85870: ColorRamp Keyframes crash Blender

The color-band needs to do some special, rather awkward updating of the
UI state when certain values are changed. As @lichtwerk noted in the
report, this was done to the wrong buttons. Now lookup the proper
buttons, and don't assume that `uiItemR()` only adds a single button
(which often isn't the case).

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

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

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

diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index a3259831c9f..b32aa82ad9e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3673,13 +3673,9 @@ static void colorband_buttons_layout(uiLayout *layout,
 
       row = uiLayoutRow(split, false);
       uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE);
-      bt = block->buttons.last;
-      UI_but_func_set(bt, colorband_update_cb, bt, coba);
 
       row = uiLayoutRow(layout, false);
       uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
-      bt = block->buttons.last;
-      UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
     }
     else {
       split = uiLayoutSplit(layout, 0.5f, false);
@@ -3704,13 +3700,28 @@ static void colorband_buttons_layout(uiLayout *layout,
 
       row = uiLayoutRow(subsplit, false);
       uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), ICON_NONE);
-      bt = block->buttons.last;
-      UI_but_func_set(bt, colorband_update_cb, bt, coba);
 
       row = uiLayoutRow(split, false);
       uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
-      bt = block->buttons.last;
-      UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+    }
+
+    /* Some special (rather awkward) treatment to update UI state on certain property changes. */
+    LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) {
+      if (but->rnapoin.data != ptr.data) {
+        continue;
+      }
+      if (!but->rnaprop) {
+        continue;
+      }
+
+      const char *prop_identifier = RNA_property_identifier(but->rnaprop);
+      if (STREQ(prop_identifier, "position")) {
+        UI_but_func_set(but, colorband_update_cb, but, coba);
+      }
+
+      if (STREQ(prop_identifier, "color")) {
+        UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL);
+      }
     }
   }
 }



More information about the Bf-blender-cvs mailing list