Prevent possible crash when mesh is freed

This commit is contained in:
Yuri Rubinsky 2022-07-06 19:24:24 +03:00
parent 09e12ba9b4
commit 3dc1a1dbfb
2 changed files with 4 additions and 0 deletions

View file

@ -64,6 +64,8 @@ void MeshStorage::mesh_free(RID p_rid) {
mesh_clear(p_rid);
mesh_set_shadow_mesh(p_rid, RID());
Mesh *mesh = mesh_owner.get_or_null(p_rid);
ERR_FAIL_COND(!mesh);
mesh->dependency.deleted_notify(p_rid);
if (mesh->instances.size()) {
ERR_PRINT("deleting mesh with active instances");

View file

@ -210,6 +210,8 @@ void MeshStorage::mesh_free(RID p_rid) {
mesh_clear(p_rid);
mesh_set_shadow_mesh(p_rid, RID());
Mesh *mesh = mesh_owner.get_or_null(p_rid);
ERR_FAIL_COND(!mesh);
mesh->dependency.deleted_notify(p_rid);
if (mesh->instances.size()) {
ERR_PRINT("deleting mesh with active instances");