From 75dad2a04b23c8848f9ade4ad70b7c352bdcdb94 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 7 Mar 2019 16:07:34 +0100 Subject: Multires: Fix crash on exit when sculpting with modifiers The SubdivCCG structure was re-allocated, but the cached one in the sculpt session was still pointing to an original one. This is rather a workaround, but is least evil from what i can currently think. Remember something similar was also required in 2.7 as well. Definitely need to revision this change. --- source/blender/modifiers/intern/MOD_multires.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 86d680554c5..7cd9dfa05aa 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -34,6 +34,7 @@ #include "BKE_mesh.h" #include "BKE_multires.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_subdiv.h" #include "BKE_subdiv_ccg.h" #include "BKE_subdiv_mesh.h" @@ -168,6 +169,14 @@ static Mesh *applyModifier(ModifierData *md, /* NOTE: CCG takes ownership over Subdiv. */ result = multires_as_ccg(mmd, ctx, mesh, subdiv); result->runtime.subdiv_ccg_tot_level = mmd->totlvl; + /* TODO(sergey): Usually it is sculpt stroke's update variants which + * takes care of this, but is possible that we need this before the + * stroke: i.e. when exiting blender right after stroke is done. + * Annoying and not so much black-boxed as far as sculpting goes, and + * surely there is a better way of solving this. */ + if (ctx->object->sculpt != NULL) { + ctx->object->sculpt->subdiv_ccg = result->runtime.subdiv_ccg; + } /* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share * this pointer. Not sure if it's needed, but might have a second look * on the ownership model here. */ -- cgit v1.2.3