diff options
author | Bastien Montagne <bastien@blender.org> | 2020-10-27 13:34:37 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-10-27 17:27:07 +0300 |
commit | 90e12e823ff0b1940e8ca8131191914a3a2be007 (patch) | |
tree | 1b994cfd059b89a8d42e65a214bc860c269a3859 /source/blender/editors/sculpt_paint/sculpt.c | |
parent | f6990c235ab9cfc8750d412e931f6f03cd28177d (diff) |
Fix T81854: crash when undoing switch between sculpt and edit mode.
The logic of `BKE_sculpt_update_object_for_edit` was not correct. such
low-level functions should typically never preform depsgraph evaluation
themselves, they should be able to rely on getting a fully evaluated
depsgraph and just get needed data from there.
Supporting that required fixing other broken code higher in the
callstack, namely:
* `ED_object_sculptmode_enter_ex` was freeing evaluated data, for no
valid reason it would seem.
* `sculpt_undosys_step_decode` was ensuring an evaluated depsgraph
**before** calling `ED_object_mode_generic_exit`, which would
invalidate a lot of evaluated data.
Note that it is fairly difficult to track down all code paths leading to
`BKE_sculpt_update_object_for_edit`, so there may be still cases where
this gets called with improperly evaluated depsgraph.
Reviewed By: sergey
Maniphest Tasks: T81854
Differential Revision: https://developer.blender.org/D9270
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index bd381a7b60c..fafa87e910c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -8133,6 +8133,7 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot) /**** Toggle operator for turning sculpt mode on or off ****/ +/** \warning Expects a fully evaluated depsgraph. */ static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob) { /* Create persistent sculpt mode data. */ @@ -8197,6 +8198,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, if (flush_recalc) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + BKE_scene_graph_evaluated_ensure(depsgraph, bmain); } /* Create sculpt mode session data. */ @@ -8204,10 +8206,6 @@ void ED_object_sculptmode_enter_ex(Main *bmain, BKE_sculptsession_free(ob); } - /* Make sure derived final from original object does not reference possibly - * freed memory. */ - BKE_object_free_derived_caches(ob); - /* Copy the current mesh visibility to the Face Sets. */ BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me); |