From 629f22f161abfbe492d71e08cc89651da683aded Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 24 Feb 2022 14:15:38 +0100 Subject: Fix T95997: Crash when entering edit mode The issue was uncovered by the 0f89bcdbebf5, 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 --- source/blender/blenkernel/intern/DerivedMesh.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 1fcf1bf1839..00a6fa6d178 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -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); } -- cgit v1.2.3