diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-01-11 16:03:47 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-01-11 16:04:12 -0300 |
commit | 5398363572309835c2f6c79d9487ae7420df1439 (patch) | |
tree | c1f26129cb674b4260faa89748b4f0731a38e57a | |
parent | 920715b97db4f3d63dfdc0f38141ce842a9bad63 (diff) |
solved particle memory leak, fixes #15591
-rw-r--r-- | scene/3d/particles.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 219464ae1f..8617bbc2f6 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -1597,4 +1597,21 @@ ParticlesMaterial::ParticlesMaterial() : } ParticlesMaterial::~ParticlesMaterial() { + + if (material_mutex) + material_mutex->lock(); + + if (shader_map.has(current_key)) { + shader_map[current_key].users--; + if (shader_map[current_key].users == 0) { + //deallocate shader, as it's no longer in use + VS::get_singleton()->free(shader_map[current_key].shader); + shader_map.erase(current_key); + } + + VS::get_singleton()->material_set_shader(_get_material(), RID()); + } + + if (material_mutex) + material_mutex->unlock(); } |