diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-08 17:22:52 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-08 17:24:07 +0300 |
commit | 0417f205f564bb883181c27db86d5639a97b0121 (patch) | |
tree | caf87a2f9eb72974f6f3fb0e330be7841ffdc7da /source/blender/editors | |
parent | f638ad61b88cbd1ca794b2a4993f20f3bc833da8 (diff) |
Fix crash with wertex and weight modes
Similar to recent sculpt mode.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index dab207d7350..5a5c76318f3 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -59,6 +59,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" +#include "BKE_object.h" #include "BKE_object_deform.h" #include "BKE_paint.h" #include "BKE_report.h" @@ -1067,6 +1068,11 @@ static void ed_vwpaintmode_enter_generic( ob->mode |= mode_flag; Mesh *me = BKE_mesh_from_object(ob); + /* Same as sculpt mode, make sure we don't have cached derived mesh which + * points to freed arrays. + */ + BKE_object_free_derived_mesh_caches(ob); + if (mode_flag == OB_MODE_VERTEX_PAINT) { const ePaintMode paint_mode = ePaintVertex; ED_mesh_color_ensure(me, NULL); @@ -1192,6 +1198,9 @@ static void ed_vwpaintmode_exit_generic( ED_mesh_mirror_topo_table(NULL, NULL, 'e'); } + /* Never leave derived meshes behind. */ + BKE_object_free_derived_mesh_caches(ob); + /* Flush object mode. */ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a59e2abdb5f..2e9d55a4c6f 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5668,11 +5668,7 @@ void ED_object_sculptmode_enter_ex( /* Make sure derived final from original object does not reference possibly * freed memory. */ - if (ob->derivedFinal != NULL) { - ob->derivedFinal->needsFree = true; - ob->derivedFinal->release(ob->derivedFinal); - ob->derivedFinal = NULL; - } + BKE_object_free_derived_mesh_caches(ob); sculpt_init_session(depsgraph, scene, ob); @@ -5801,6 +5797,9 @@ void ED_object_sculptmode_exit_ex( paint_cursor_delete_textures(); + /* Never leave derived meshes behind. */ + BKE_object_free_derived_mesh_caches(ob); + /* Flush object mode. */ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); } |