evas: Evas_3D - add destructors for clean of memory.

Summary: Update and add new destructors.

Reviewers: Hermet, raster, cedric

Reviewed By: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2029
This commit is contained in:
se.osadchy 2015-02-23 14:42:42 +01:00 committed by Cedric BAIL
parent d5c5d56752
commit cd4c0324ec
7 changed files with 79 additions and 11 deletions

View File

@ -74,8 +74,22 @@ EOLIAN static void
_evas_3d_camera_eo_base_destructor(Eo *obj,
Evas_3D_Camera_Data *pd)
{
//evas_3d_object_unreference(&pd->base);
if (pd->nodes) eina_hash_free(pd->nodes);
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_3D_Node_Data *node = NULL;
if (pd->nodes)
{
it = eina_hash_iterator_key_new(pd->nodes);
while (eina_iterator_next(it, &data))
{
node = eo_data_scope_get(data, EVAS_3D_NODE_CLASS);
node->data.camera.camera = NULL;
}
eina_hash_free(pd->nodes);
}
eo_do_super(obj, MY_CLASS, eo_destructor());
}

View File

@ -97,8 +97,22 @@ _evas_3d_light_eo_base_constructor(Eo *obj, Evas_3D_Light_Data *pd)
EOLIAN static void
_evas_3d_light_eo_base_destructor(Eo *obj, Evas_3D_Light_Data *pd)
{
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_3D_Node_Data *node = NULL;
if (pd->nodes)
eina_hash_free(pd->nodes);
{
it = eina_hash_iterator_key_new(pd->nodes);
while (eina_iterator_next(it, &data))
{
node = eo_data_scope_get(data, EVAS_3D_NODE_CLASS);
node->data.light.light = NULL;
}
eina_hash_free(pd->nodes);
}
eo_do_super(obj, MY_CLASS, eo_destructor());
}

View File

@ -104,17 +104,34 @@ _evas_3d_material_eo_base_constructor(Eo *obj EINA_UNUSED, Evas_3D_Material_Data
EOLIAN static void
_evas_3d_material_eo_base_destructor(Eo *obj, Evas_3D_Material_Data *pd)
{
int i;
int i = 0;
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_3D_Mesh_Data *mesh = NULL;
Eina_List *l = NULL;
Evas_3D_Mesh_Frame *f = NULL;
if (pd->meshes)
eina_hash_free(pd->meshes);
{
it = eina_hash_iterator_key_new(pd->meshes);
while (eina_iterator_next(it, &data))
{
mesh = eo_data_scope_get(data, EVAS_3D_MESH_CLASS);
if (mesh->frames)
{
EINA_LIST_FOREACH(mesh->frames, l, f)
f->material = NULL;
}
}
eina_iterator_free(it);
eina_hash_free(pd->meshes);
}
for (i = 0; i < EVAS_3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (pd->attribs[i].texture)
{
evas_3d_texture_material_del(pd->attribs[i].texture, obj);
//eo_unref(pd->attribs[i].texture);
}
}
eo_do_super(obj, MY_CLASS, eo_destructor());

View File

@ -259,7 +259,6 @@ _evas_3d_mesh_eo_base_constructor(Eo *obj, Evas_3D_Mesh_Data *pd)
EOLIAN static void
_evas_3d_mesh_eo_base_destructor(Eo *obj, Evas_3D_Mesh_Data *pd)
{
//evas_3d_object_unreference(&pd->base);
_mesh_fini(pd);
eo_do_super(obj, MY_CLASS, eo_destructor());
}

View File

@ -628,7 +628,6 @@ _node_free(Evas_3D_Object *obj)
EINA_LIST_FOREACH(pd->data.mesh.meshes, l, m)
{
//evas_3d_mesh_node_del(m, node);
eo_unref(m);
}
@ -643,8 +642,6 @@ _node_free(Evas_3D_Object *obj)
if (pd->scenes_camera)
eina_hash_free(pd->scenes_camera);
//free(node);
}
void
@ -1048,6 +1045,14 @@ _evas_3d_node_constructor(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Node_Type type
}
}
EOLIAN static void
_evas_3d_node_eo_base_destructor(Eo *obj, Evas_3D_Node_Data *pd EINA_UNUSED)
{
_node_free(obj);
eo_do_super(obj, MY_CLASS, eo_destructor());
}
EOLIAN static Evas_3D_Node_Type
_evas_3d_node_type_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd)
{

View File

@ -578,6 +578,7 @@ class Evas_3D_Node (Evas_3D_Object, Evas.Common_Interface)
}
}
implements {
Eo.Base.destructor;
Evas_3D_Object.update_notify;
Evas_3D_Object.change_notify;
Evas_3D_Object.callback_register;

View File

@ -161,8 +161,14 @@ static void
_texture_fini(Evas_3D_Texture *obj)
{
Eo *evas = NULL;
int i = 0;
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_3D_Material_Data *material = NULL;
eo_do(obj, evas = evas_common_evas_get());
Evas_3D_Texture_Data *pd = eo_data_scope_get(obj, MY_CLASS);
if (pd->engine_data)
{
Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
@ -173,6 +179,19 @@ _texture_fini(Evas_3D_Texture *obj)
if (pd->materials)
{
it = eina_hash_iterator_key_new(pd->materials);
EINA_ITERATOR_FOREACH(it, data)
{
material = eo_data_scope_get(data, EVAS_3D_MATERIAL_CLASS);
if (!material) continue;
for (i = 0; i < EVAS_3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (material->attribs[i].texture)
evas_3d_texture_material_del(material->attribs[i].texture, data);
}
}
eina_iterator_free(it);
eina_hash_free(pd->materials);
pd->materials = NULL;
}
@ -311,7 +330,6 @@ _evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUS
EOLIAN static void
_evas_3d_texture_eo_base_destructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUSED)
{
//evas_3d_object_unreference(&pd->base);
_texture_fini(obj);
eo_do_super(obj, MY_CLASS, eo_destructor());
}