diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-03-22 19:54:27 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-03-22 19:54:27 +0300 |
commit | 4c7ea01cbdc3ed0c37c9ea8e5cc223ee2fa1926b (patch) | |
tree | b66fc3007968e9ca46bae9f2fce8ab4020fb5aec /source/blender/editors/sculpt_paint/sculpt_undo.c | |
parent | bb3584e3cb13cb1115023066e74cbfa735410d1b (diff) |
temp-sculpt-colors: Fix crash in redoing after
undoing first stroke of
paint brush.
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 9 |
1 files changed, 9 insertions, 0 deletions
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); |