[Bf-blender-cvs] [4c7ea01cbdc] temp-sculpt-colors: temp-sculpt-colors: Fix crash in redoing after undoing first stroke of paint brush.
Joseph Eagar
noreply at git.blender.org
Tue Mar 22 17:55:05 CET 2022
Commit: 4c7ea01cbdc3ed0c37c9ea8e5cc223ee2fa1926b
Author: Joseph Eagar
Date: Tue Mar 22 09:54:27 2022 -0700
Branches: temp-sculpt-colors
https://developer.blender.org/rB4c7ea01cbdc3ed0c37c9ea8e5cc223ee2fa1926b
temp-sculpt-colors: Fix crash in redoing after
undoing first stroke of
paint brush.
===================================================================
M source/blender/draw/intern/draw_cache_impl_mesh.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 2e1881b0346..2fa49d3025c 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -693,6 +693,8 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
break;
}
+ /* Note: this is the logical index into the color attribute list,
+ not the customdata index. */
int layer_i = BKE_id_attribute_to_index(
(ID *)&query_mesh, layer, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index d6ee1a91a1f..fcdce9a59b1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1562,6 +1562,15 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr
CustomDataLayer *layer;
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
+ if (!layer) {
+ /* memfile undo killed the layer; re-create it */
+ CustomData *cdata = attr->domain == ATTR_DOMAIN_POINT ? &me->vdata : &me->ldata;
+ int totelem = attr->domain == ATTR_DOMAIN_POINT ? me->totvert : me->totloop;
+
+ CustomData_add_layer_named(cdata, attr->type, CD_DEFAULT, NULL, totelem, attr->name);
+ layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
+ }
+
if (layer) {
BKE_id_attributes_active_color_set(&me->id, layer);
More information about the Bf-blender-cvs
mailing list