Fix T95997: Crash when entering edit mode

The issue was uncovered by the 0f89bcdbeb, but the root cause goes
into a much earlier design violation happened in the code: the modifier
evaluation function is modifying input mesh, which is not something
what is ever expected.

Bring code closer to the older state where such modification is only
done for the object in edit mode.

---

From own tests works seems to work fine, but extra eyes and testing
is needed.

Differential Revision: https://developer.blender.org/D14191
This commit is contained in:
Sergey Sharybin 2022-02-24 14:15:38 +01:00
parent cde5e12c0b
commit 629f22f161
Notes: blender-bot 2023-02-14 08:49:53 +01:00
Referenced by issue #96133, MacOS desktop freeze and crash on 3.1 beta up to 3.2.2 when moving mesh in Cycles Rendered view (Cycles CPU mode)
Referenced by issue #95997, [3.1] Crash when entering edit mode
1 changed files with 3 additions and 1 deletions

View File

@ -1667,7 +1667,9 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
}
else {
Mesh *me_orig = mesh_input;
if (me_orig->id.tag & LIB_TAG_COPIED_ON_WRITE) {
/* Modifying the input mesh is weak, however as there can only be one object in edit mode
* even if multiple are sharing the same mesh this should be thread safe. */
if ((me_orig->id.tag & LIB_TAG_COPIED_ON_WRITE) && (ob->mode & OB_MODE_EDIT)) {
if (!BKE_mesh_runtime_ensure_edit_data(me_orig)) {
BKE_mesh_runtime_reset_edit_data(me_orig);
}