Fix T91123: Freeing meshes in edit-mode leaks memory
Freeing the edit-mesh pointer wasn't free the edit-mesh data it's self. Unlinking from the outliner or through the Python API leaked memory. This didn't often cause leaks in practice since ED_editors_exit exits edit-mode for all objects. Now freeing mesh data frees the edit-mode data as well, this matches the behavior of other object types that support edit-mode.
This commit is contained in:
parent
809b33b69a
commit
0708733c46
Notes:
blender-bot
2023-02-14 08:39:23 +01:00
Referenced by commita8739ae6c2
, Fix regression in recent change0708733c46
Referenced by issue #91123, Freeing meshes in edit-mode leaks memory
|
@ -211,10 +211,14 @@ void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em,
|
|||
void BKE_editmesh_free_derived_caches(BMEditMesh *em)
|
||||
{
|
||||
if (em->mesh_eval_cage) {
|
||||
BKE_id_free(NULL, em->mesh_eval_cage);
|
||||
Mesh *me = em->mesh_eval_cage;
|
||||
MEM_SAFE_FREE(me->edit_mesh);
|
||||
BKE_id_free(NULL, me);
|
||||
}
|
||||
if (em->mesh_eval_final && em->mesh_eval_final != em->mesh_eval_cage) {
|
||||
BKE_id_free(NULL, em->mesh_eval_final);
|
||||
Mesh *me = em->mesh_eval_final;
|
||||
MEM_SAFE_FREE(me->edit_mesh);
|
||||
BKE_id_free(NULL, me);
|
||||
}
|
||||
em->mesh_eval_cage = em->mesh_eval_final = NULL;
|
||||
|
||||
|
|
|
@ -160,6 +160,12 @@ static void mesh_free_data(ID *id)
|
|||
|
||||
BLI_freelistN(&mesh->vertex_group_names);
|
||||
|
||||
if (mesh->edit_mesh) {
|
||||
BKE_editmesh_free_data(mesh->edit_mesh);
|
||||
MEM_freeN(mesh->edit_mesh);
|
||||
mesh->edit_mesh = NULL;
|
||||
}
|
||||
|
||||
BKE_mesh_runtime_clear_cache(mesh);
|
||||
mesh_clear_geometry(mesh);
|
||||
MEM_SAFE_FREE(mesh->mat);
|
||||
|
|
Loading…
Reference in New Issue