Fix T55015: Crash on selection after recent BVH changes

Runtime data should always be initialized to NULL on read-time.
This commit is contained in:
Dalai Felinto 2018-05-09 15:38:58 +02:00
parent ed23bd5f3c
commit 828a3d89b3
Notes: blender-bot 2023-02-14 08:07:50 +01:00
Referenced by issue #55015, Crash on selection after recent BVH changes
3 changed files with 10 additions and 3 deletions

View File

@ -192,7 +192,7 @@ void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type);
void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]);
/* *** mesh_runtime.c *** */
void BKE_mesh_runtime_reset(struct Mesh *mesh);
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
void BKE_mesh_runtime_looptri_recalc(struct Mesh *mesh);
const struct MLoopTri *BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh);

View File

@ -44,6 +44,13 @@
static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
/**
* Default values defined at read time.
*/
void BKE_mesh_runtime_reset(Mesh *mesh)
{
memset(&mesh->runtime, 0, sizeof(mesh->runtime));
}
/* This is a ported copy of DM_ensure_looptri_data(dm) */
/**

View File

@ -4685,8 +4685,8 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
mesh->bb = NULL;
mesh->edit_btmesh = NULL;
mesh->runtime.batch_cache = NULL;
BKE_mesh_runtime_reset(mesh);
/* happens with old files */
if (mesh->mselect == NULL) {
mesh->totselect = 0;