From 352474ced8e1e7c34b08c20dafd594b92eda6f14 Mon Sep 17 00:00:00 2001 From: George Vogiatzis Date: Thu, 23 May 2019 13:57:03 +0200 Subject: Fix T65002: after hiding edit mode object, clicking in wireframe mode crashes Differential Revision: https://developer.blender.org/D4926 --- source/blender/editors/mesh/editmesh_select.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index dc94219cb9a..0aa160453b5 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -279,7 +279,7 @@ BMElem *EDBM_select_id_bm_elem_get(struct EDBMSelectID_Context *sel_id_ctx, const uint sel_id, uint *r_base_index) { - char elem_type; + char elem_type = 0; uint elem_id; uint base_index = 0; for (; base_index < sel_id_ctx->bases_len; base_index++) { @@ -504,7 +504,7 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, } else { struct NearestVertUserData data = {{0}}; - const struct NearestVertUserData_Hit *hit; + const struct NearestVertUserData_Hit *hit = NULL; const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT; BMesh *prev_select_bm = NULL; @@ -549,6 +549,10 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, } } + if (hit == NULL) { + return NULL; + } + prev_select.index = hit->index; prev_select.elem = hit->vert; prev_select.bm = prev_select_bm; @@ -751,7 +755,7 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc, } else { struct NearestEdgeUserData data = {{0}}; - const struct NearestEdgeUserData_Hit *hit; + const struct NearestEdgeUserData_Hit *hit = NULL; /* interpolate along the edge before doing a clipping plane test */ const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT & ~V3D_PROJ_TEST_CLIP_BB; BMesh *prev_select_bm = NULL; @@ -798,6 +802,10 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc, } } + if (hit == NULL) { + return NULL; + } + if (r_dist_center) { *r_dist_center = hit->dist_center; } @@ -960,7 +968,7 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, } else { struct NearestFaceUserData data = {{0}}; - const struct NearestFaceUserData_Hit *hit; + const struct NearestFaceUserData_Hit *hit = NULL; const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT; BMesh *prev_select_bm = NULL; @@ -1005,6 +1013,10 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, } } + if (hit == NULL) { + return NULL; + } + if (r_dist_center) { *r_dist_center = hit->dist; } -- cgit v1.2.3