[Bf-blender-cvs] [bcf91617b3b] sculpt-dev: Sculpt-dev: fix crash

Joseph Eagar noreply at git.blender.org
Fri Nov 19 15:59:29 CET 2021


Commit: bcf91617b3b3a7fda86189f5102bf65b0b4890e0
Author: Joseph Eagar
Date:   Fri Nov 19 06:58:54 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rBbcf91617b3b3a7fda86189f5102bf65b0b4890e0

Sculpt-dev: fix crash

* Tool slots weren't initializes sculpt
  brushes properly.

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

M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/editors/sculpt_paint/paint_ops.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 7cf728c8e9e..72f474b8163 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -1105,6 +1105,14 @@ void brush_channel_apply_mapping_flags(BrushChannel *ch, BrushChannel *child, Br
     BrushMapping *cmp = child ? child->mappings + i : NULL;
     BrushMapping *pmp = parent ? parent->mappings + i : NULL;
 
+    if (!cmp) {
+      if (pmp) {
+        *mp = *pmp;
+      }
+
+      continue;
+    }
+
     if (pmp && brush_mapping_inherits(child, cmp)) {
       *mp = *pmp;
     }
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 330c7ebcd21..65933c1b655 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -660,9 +660,17 @@ static int brush_tool(const Brush *brush, size_t tool_offset)
   return *(((char *)brush) + tool_offset);
 }
 
-static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool)
+static void brush_tool_set(Brush *brush, size_t tool_offset, int tool)
 {
   *(((char *)brush) + tool_offset) = tool;
+
+  if (tool_offset == offsetof(Brush, sculpt_tool)) {
+    if (!brush->channels) {
+      brush->channels = BKE_brush_channelset_create(__func__);
+    }
+
+    BKE_brush_builtin_patch(brush, tool);
+  }
 }
 
 static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c9846021b1c..daefa621981 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -8401,6 +8401,9 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
         channels = sculpt_init_tool_override_channels(sd, ob->sculpt, tool);
       }
 
+      //paranoia check to correct corrupted brushes
+      BKE_brush_builtin_patch(brush, brush->sculpt_tool);
+
       BKE_brush_channelset_compat_load(sculpt_get_brush_channels(ob->sculpt, brush), brush, false);
 
       if (tool) {



More information about the Bf-blender-cvs mailing list