[Bf-blender-cvs] [629f22f161a] blender-v3.1-release: Fix T95997: Crash when entering edit mode

Sergey Sharybin noreply at git.blender.org
Tue Mar 1 11:46:42 CET 2022


Commit: 629f22f161abfbe492d71e08cc89651da683aded
Author: Sergey Sharybin
Date:   Thu Feb 24 14:15:38 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB629f22f161abfbe492d71e08cc89651da683aded

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

===================================================================

M	source/blender/blenkernel/intern/DerivedMesh.cc

===================================================================

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);
           }



More information about the Bf-blender-cvs mailing list