From 6f4e595e9ba9d7ac79873a1dc0a98144e6f136cb Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 20 Aug 2019 11:57:30 +0200 Subject: [PATCH] Fix T68852: Link select crashes after knife project Knife project switches out of vertex selection mode, but wouldnt do this for all participating meshes. Logic in edbm_select_linked_pick would switch the viewcontext multiple times and the meshes selectmode was not in sync then, leading e.g. finding a vertex in 'unified_findnearest' (because last of the meshes selectmode was SCE_SELECT_VERTEX), but then later in 'EDBM_elem_from_selectmode' other meshes selectmode was not matching SCE_SELECT_VERTEX, leading to crash... Reviewers: campbellbarton Maniphest Tasks: T68852 Differential Revision: https://developer.blender.org/D5536 --- .../editors/mesh/editmesh_knife_project.c | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index 3d34a4ad3b5..a709bd010aa 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -22,6 +22,7 @@ */ #include "DNA_curve_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "BLI_math.h" @@ -142,10 +143,21 @@ static int knifeproject_exec(bContext *C, wmOperator *op) /* select only tagged faces */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); - /* not essential, but switch out of vertex mode since the - * selected regions wont be nicely isolated after flushing. - * note: call after de-select to avoid selection flushing */ - EDBM_selectmode_disable(scene, em, SCE_SELECT_VERTEX, SCE_SELECT_EDGE); + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { + if (ob->type == OB_MESH) { + Mesh *me = (Mesh *)ob->data; + BMEditMesh *embm = me->edit_mesh; + if (embm) { + /* not essential, but switch out of vertex mode since the + * selected regions wont be nicely isolated after flushing. + * note: call after de-select to avoid selection flushing. + * note: do this on all participating meshes so this is in sync + * e.g. for later selection picking, see T68852.*/ + EDBM_selectmode_disable(scene, embm, SCE_SELECT_VERTEX, SCE_SELECT_EDGE); + } + } + } + CTX_DATA_END; BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);