[Bf-blender-cvs] [8a9dedf8295] master: Workaround T84084: Assert/crash when undoing from Sculpt mode to Object one.

Bastien Montagne noreply at git.blender.org
Wed Dec 23 16:06:23 CET 2020


Commit: 8a9dedf829544e30f822bcb016a9c134af6979e5
Author: Bastien Montagne
Date:   Wed Dec 23 16:01:24 2020 +0100
Branches: master
https://developer.blender.org/rB8a9dedf829544e30f822bcb016a9c134af6979e5

Workaround T84084: Assert/crash when undoing from Sculpt mode to Object one.

Disclaimer: This workaround avoids crashing with current state of the
code and is only committed as temporary band-aid until we can assess the
full issue and decide if/how it needs to be adressed.

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

M	source/blender/blenkernel/intern/multires_reshape_ccg.c

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

diff --git a/source/blender/blenkernel/intern/multires_reshape_ccg.c b/source/blender/blenkernel/intern/multires_reshape_ccg.c
index 55f7766c878..aa003909bb0 100644
--- a/source/blender/blenkernel/intern/multires_reshape_ccg.c
+++ b/source/blender/blenkernel/intern/multires_reshape_ccg.c
@@ -61,8 +61,24 @@ bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext
                sizeof(float[3]));
 
         if (reshape_level_key.has_mask) {
-          BLI_assert(grid_element.mask != NULL);
-          *grid_element.mask = *CCG_grid_elem_mask(&reshape_level_key, ccg_grid, x, y);
+          /* Assert about a non-NULL `grid_element.mask` may fail here, this code may be called
+           * from cleanup code during COW evaluation phase by depsgraph (e.g.
+           * `object_update_from_subsurf_ccg` call in `BKE_object_free_derived_caches`).
+           *
+           * `reshape_level_key.has_mask` is ultimately set from MultiRes modifier apply code
+           * (through `multires_as_ccg` -> `multires_ccg_settings_init`), when object is in sculpt
+           * mode only, and there is matching loop cdlayer.
+           *
+           * `grid_element.mask` is directly set from existing matching loop cdlayer during
+           * initialization of `MultiresReshapeContext` struct.
+           *
+           * Since ccg data is preserved during undos, we may end up with a state where there is no
+           * mask data in mesh loops' cdlayer, while ccg's `has_mask` is still set to true.
+           */
+          // BLI_assert(grid_element.mask != NULL);
+          if (grid_element.mask != NULL) {
+            *grid_element.mask = *CCG_grid_elem_mask(&reshape_level_key, ccg_grid, x, y);
+          }
         }
       }
     }



More information about the Bf-blender-cvs mailing list