fixed bug removing dependencies

This commit is contained in:
Juan Linietsky 2016-11-24 23:30:54 -03:00
parent a732708b9d
commit 3f40701002
2 changed files with 25 additions and 4 deletions

View file

@ -5272,6 +5272,7 @@ bool RasterizerStorageGLES3::free(RID p_rid){
// delete the texture // delete the texture
Shader *shader = shader_owner.get(p_rid); Shader *shader = shader_owner.get(p_rid);
if (shader->shader) if (shader->shader)
shader->shader->free_custom_shader(shader->custom_code_id); shader->shader->free_custom_shader(shader->custom_code_id);
@ -5348,7 +5349,7 @@ bool RasterizerStorageGLES3::free(RID p_rid){
// delete the texture // delete the texture
Mesh *mesh = mesh_owner.get(p_rid); Mesh *mesh = mesh_owner.get(p_rid);
mesh->instance_remove_deps();
mesh_clear(p_rid); mesh_clear(p_rid);
mesh_owner.free(p_rid); mesh_owner.free(p_rid);
@ -5358,6 +5359,7 @@ bool RasterizerStorageGLES3::free(RID p_rid){
// delete the texture // delete the texture
MultiMesh *multimesh = multimesh_owner.get(p_rid); MultiMesh *multimesh = multimesh_owner.get(p_rid);
multimesh->instance_remove_deps();
multimesh_allocate(p_rid,0,VS::MULTIMESH_TRANSFORM_2D,VS::MULTIMESH_COLOR_NONE); //frees multimesh multimesh_allocate(p_rid,0,VS::MULTIMESH_TRANSFORM_2D,VS::MULTIMESH_COLOR_NONE); //frees multimesh
update_dirty_multimeshes(); update_dirty_multimeshes();
@ -5367,6 +5369,7 @@ bool RasterizerStorageGLES3::free(RID p_rid){
} else if (immediate_owner.owns(p_rid)) { } else if (immediate_owner.owns(p_rid)) {
Immediate *immediate = immediate_owner.get(p_rid); Immediate *immediate = immediate_owner.get(p_rid);
immediate->instance_remove_deps();
immediate_owner.free(p_rid); immediate_owner.free(p_rid);
memdelete(immediate); memdelete(immediate);
@ -5374,10 +5377,20 @@ bool RasterizerStorageGLES3::free(RID p_rid){
// delete the texture // delete the texture
Light *light = light_owner.get(p_rid); Light *light = light_owner.get(p_rid);
light->instance_remove_deps();
light_owner.free(p_rid); light_owner.free(p_rid);
memdelete(light); memdelete(light);
} else if (reflection_probe_owner.owns(p_rid)) {
// delete the texture
ReflectionProbe *reflection_probe = reflection_probe_owner.get(p_rid);
reflection_probe->instance_remove_deps();
reflection_probe_owner.free(p_rid);
memdelete(reflection_probe);
} else if (canvas_occluder_owner.owns(p_rid)) { } else if (canvas_occluder_owner.owns(p_rid)) {

View file

@ -130,12 +130,20 @@ public:
} }
} }
_FORCE_INLINE_ void instance_remove_deps() {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while(instances) {
SelfList<RasterizerScene::InstanceBase> *next = instances->next();
instances->self()->base_removed();
instances=next;
}
}
Instantiable() { } Instantiable() { }
virtual ~Instantiable() { virtual ~Instantiable() {
while(instance_list.first()) {
instance_list.first()->self()->base_removed();
}
} }
}; };