evas: fix initialisation and shutdown of eet and eina by mesh loader and saver.
authorCedric BAIL <cedric@osg.samsung.com>
Wed, 6 Jul 2016 20:26:15 +0000 (13:26 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Wed, 6 Jul 2016 20:26:15 +0000 (13:26 -0700)
src/lib/evas/canvas/evas_canvas3d_eet.c
src/modules/evas/model_loaders/eet/evas_model_load_eet.c
src/modules/evas/model_savers/eet/evas_model_save_eet.c
src/tests/evas/evas_tests_helpers.h

index 4a0cc4f..0c43e06 100644 (file)
@@ -208,6 +208,4 @@ _evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file)
      }
 
    _evas_canvas3d_eet_descriptor_shutdown();
-   eet_shutdown();
-   eina_shutdown();
 }
index c17e984..b3ae3ba 100644 (file)
@@ -8,7 +8,7 @@
 #include "evas_common_private.h"
 #include "evas_private.h"
 
-void
+static void
 _set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
                                     Evas_Canvas3D_Mesh_Eet *eet_mesh)
 {
@@ -59,7 +59,7 @@ _set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
    evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
 }
 
-void
+static void
 _set_material_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
                                     Evas_Canvas3D_Mesh_Eet *eet_mesh)
 {
@@ -86,6 +86,7 @@ evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
    Evas_Canvas3D_File_Eet* eet_file;
    Eet_Data_Descriptor *_file_descriptor;
 
+   eet_init();
 
    _file_descriptor = _evas_canvas3d_eet_file_get();
    ef = eet_mmap(file);
@@ -98,12 +99,13 @@ evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
    if (!eet_file || !eet_file->mesh || !eet_file->header)
      {
         ERR("Failed to read model file");
-        _evas_canvas3d_eet_file_free(eet_file);
-        return;
+        goto on_error;
      }
 
    _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh);
    _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh);
 
+ on_error:
    _evas_canvas3d_eet_file_free(eet_file);
+   eet_shutdown();
 }
index ec1857a..89c7c89 100644 (file)
@@ -10,7 +10,7 @@
 #define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3
 #define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5
 
-void
+static void
 _set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh,
                                     Evas_Canvas3D_Mesh_Eet *eet_mesh,
                                     Evas_Canvas3D_Header_Eet *eet_header,
@@ -64,7 +64,7 @@ _set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh,
    eet_header->geometries = geometries;
 }
 
-void
+static void
 _set_material_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Eet *eet_mesh,
                                     Evas_Canvas3D_Header_Eet *eet_header,
                                     Evas_Canvas3D_Mesh_Frame *f)
@@ -125,7 +125,7 @@ _set_material_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Eet *eet_mesh,
    eet_header->materials = materials;
 }
 
-void
+static void
 _set_frame_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Eet *eet_mesh)
 {
    eet_mesh->frames = malloc(sizeof(Evas_Canvas3D_Frame_Eet));
@@ -147,12 +147,16 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
                          Evas_Canvas3D_Mesh_Frame *f)
 {
    Evas_Canvas3D_Mesh_Data *pd = eo_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
-   Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE);
+   Eet_File *ef;
    Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet));
    Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet));
    Eet_Data_Descriptor *_file_descriptor;
    Evas_Canvas3D_File_Eet *eet_file;
 
+   eet_init();
+
+   ef = eet_open(file, EET_FILE_MODE_WRITE);
+
    _file_descriptor = _evas_canvas3d_eet_file_get();
 
    eet_file = _evas_canvas3d_eet_file_new();
@@ -174,8 +178,8 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
         ERR("Opening of file is failed.");
         free(eet_mesh);
         free(eet_header);
-        _evas_canvas3d_eet_file_free(eet_file);
-        return;
+
+        goto on_error;
      }
 
    eet_file->mesh = eet_mesh;
@@ -188,5 +192,8 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
                   EINA_TRUE);
    eet_close(ef);
 
+ on_error:
    _evas_canvas3d_eet_file_free(eet_file);
+
+   eet_shutdown();
 }