From 4c7ea01cbdc3ed0c37c9ea8e5cc223ee2fa1926b Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Tue, 22 Mar 2022 09:54:27 -0700 Subject: temp-sculpt-colors: Fix crash in redoing after undoing first stroke of paint brush. --- source/blender/editors/sculpt_paint/sculpt_undo.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c') 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); -- cgit v1.2.3