From 9527240d7422ff828f29c54df2211dd9374c2867 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Mon, 4 Jul 2016 20:07:30 +0900 Subject: [PATCH] efl - fix lots of little init/shutdown pairs that are wrong i've fixed almost all the eina init/shutdown pairs to do the right thing now... except one (ecore_shutdown) with comment inline where eo_shutdown is not called. if this is called we are in crash land. this needs further inspection. --- src/lib/ecore/ecore.c | 5 ++-- src/lib/efreet/efreet_cache.c | 3 +++ src/lib/embryo/embryo_main.c | 1 + src/lib/evas/canvas/evas_canvas3d_eet.c | 3 --- src/lib/evas/canvas/evas_main.c | 7 +++++ src/lib/evas/file/evas_module.c | 30 +++++++++++++++++++++- src/modules/ecore_imf/xim/ecore_imf_xim.c | 1 - .../evas/image_loaders/eet/evas_image_load_eet.c | 2 -- .../evas/model_loaders/ply/evas_model_load_ply.c | 2 -- .../evas/model_savers/obj/evas_model_save_obj.c | 2 -- 10 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index 5a9e2d2..6431a64 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -439,13 +439,14 @@ ecore_shutdown(void) eina_prefix_free(_ecore_pfx); _ecore_pfx = NULL; + eo_unref(_ecore_parent); + eo_shutdown(); + eina_shutdown(); #ifdef HAVE_EVIL evil_shutdown(); #endif - eo_unref(_ecore_parent); - eo_shutdown(); end: return _ecore_init_count; } diff --git a/src/lib/efreet/efreet_cache.c b/src/lib/efreet/efreet_cache.c index 88fda2e..4211ca7 100644 --- a/src/lib/efreet/efreet_cache.c +++ b/src/lib/efreet/efreet_cache.c @@ -360,6 +360,9 @@ efreet_cache_shutdown(void) if (hnd_add) ecore_event_handler_del(hnd_add); if (hnd_del) ecore_event_handler_del(hnd_del); if (hnd_data) ecore_event_handler_del(hnd_data); + + ecore_ipc_shutdown(); + ipc = NULL; pfx = NULL; hnd_add = NULL; diff --git a/src/lib/embryo/embryo_main.c b/src/lib/embryo/embryo_main.c index 37fc811..4b2af3c 100644 --- a/src/lib/embryo/embryo_main.c +++ b/src/lib/embryo/embryo_main.c @@ -64,6 +64,7 @@ embryo_shutdown(void) eina_log_domain_unregister(_embryo_default_log_dom); _embryo_default_log_dom = -1; + eina_shutdown(); return _embryo_init_count; } diff --git a/src/lib/evas/canvas/evas_canvas3d_eet.c b/src/lib/evas/canvas/evas_canvas3d_eet.c index 353e291..4a0cc4f 100644 --- a/src/lib/evas/canvas/evas_canvas3d_eet.c +++ b/src/lib/evas/canvas/evas_canvas3d_eet.c @@ -37,9 +37,6 @@ _evas_canvas3d_eet_file_get() void _evas_canvas3d_eet_file_init() { - eina_init(); - eet_init(); - /* initialization of bonding between structure units in eet file */ Eet_Data_Descriptor_Class eddc; EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vec2_Eet); diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c index f2c9b44..7f7afa2 100644 --- a/src/lib/evas/canvas/evas_main.c +++ b/src/lib/evas/canvas/evas_main.c @@ -43,6 +43,9 @@ evas_init(void) if (!eina_init()) goto shutdown_evil; + if (!eet_init()) + goto shutdown_eet; + _evas_log_dom_global = eina_log_domain_register ("evas_main", EVAS_DEFAULT_LOG_COLOR); if (_evas_log_dom_global < 0) @@ -81,6 +84,8 @@ evas_init(void) shutdown_module: evas_module_shutdown(); eina_log_domain_unregister(_evas_log_dom_global); + shutdown_eet: + eet_shutdown(); shutdown_eina: eina_shutdown(); shutdown_evil: @@ -145,6 +150,8 @@ evas_shutdown(void) eina_log_domain_unregister(_evas_log_dom_global); + eet_shutdown(); + eina_shutdown(); #ifdef HAVE_EVIL evil_shutdown(); diff --git a/src/lib/evas/file/evas_module.c b/src/lib/evas/file/evas_module.c index cda2daf..a684f84 100644 --- a/src/lib/evas/file/evas_module.c +++ b/src/lib/evas/file/evas_module.c @@ -406,6 +406,13 @@ evas_module_unregister(const Evas_Module_Api *module, Evas_Module_Type type) eina_array_data_set(evas_engines, em->id_engine - 1, NULL); eina_hash_del(evas_modules[type], module->name, em); + + if (em->loaded) + { + em->definition->func.close(em); + em->loaded = 0; + } + LKD(em->lock); free(em); @@ -431,7 +438,11 @@ evas_module_find_type(Evas_Module_Type type, const char *name) if ((unsigned int)type > 3) return NULL; em = eina_hash_find(evas_modules[type], name); - if (em) return em; + if (em) + { + evas_module_load(em); + return em; + } run_in_tree = !!getenv("EFL_RUN_IN_TREE"); @@ -607,6 +618,18 @@ evas_module_clean(void) static Eina_Prefix *pfx = NULL; +static Eina_Bool +_cb_mod_close(const Eina_Hash *hash EINA_UNUSED, + const void *key EINA_UNUSED, + void *data, void *fdata EINA_UNUSED) +{ + Evas_Module *em = data; + + em->definition->func.close(em); + em->loaded = 0; + return EINA_TRUE; +} + /* will dlclose all the modules loaded and free all the structs */ void evas_module_shutdown(void) @@ -629,6 +652,11 @@ evas_module_shutdown(void) // eina_module_free(en); } + eina_hash_foreach(evas_modules[EVAS_MODULE_TYPE_ENGINE], _cb_mod_close, NULL); + eina_hash_foreach(evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER], _cb_mod_close, NULL); + eina_hash_foreach(evas_modules[EVAS_MODULE_TYPE_IMAGE_SAVER], _cb_mod_close, NULL); + eina_hash_foreach(evas_modules[EVAS_MODULE_TYPE_OBJECT], _cb_mod_close, NULL); + eina_hash_free(evas_modules[EVAS_MODULE_TYPE_ENGINE]); evas_modules[EVAS_MODULE_TYPE_ENGINE] = NULL; eina_hash_free(evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER]); diff --git a/src/modules/ecore_imf/xim/ecore_imf_xim.c b/src/modules/ecore_imf/xim/ecore_imf_xim.c index 99213a4..5258c74 100644 --- a/src/modules/ecore_imf/xim/ecore_imf_xim.c +++ b/src/modules/ecore_imf/xim/ecore_imf_xim.c @@ -767,7 +767,6 @@ _ecore_imf_xim_init(void) if (_ecore_imf_xim_log_dom < 0) { EINA_LOG_ERR("Could not register log domain: ecore_imf_xim"); - return EINA_FALSE; } DBG(" "); diff --git a/src/modules/evas/image_loaders/eet/evas_image_load_eet.c b/src/modules/evas/image_loaders/eet/evas_image_load_eet.c index 4e1f168..9ff212f 100644 --- a/src/modules/evas/image_loaders/eet/evas_image_load_eet.c +++ b/src/modules/evas/image_loaders/eet/evas_image_load_eet.c @@ -237,7 +237,6 @@ static int module_open(Evas_Module *em) { if (!em) return 0; - eet_init(); em->functions = (void *)(&evas_image_load_eet_func); return 1; } @@ -245,7 +244,6 @@ module_open(Evas_Module *em) static void module_close(Evas_Module *em EINA_UNUSED) { - eet_shutdown(); } static Evas_Module_Api evas_modapi = diff --git a/src/modules/evas/model_loaders/ply/evas_model_load_ply.c b/src/modules/evas/model_loaders/ply/evas_model_load_ply.c index 9135a00..eb4228b 100644 --- a/src/modules/evas/model_loaders/ply/evas_model_load_ply.c +++ b/src/modules/evas/model_loaders/ply/evas_model_load_ply.c @@ -44,8 +44,6 @@ _read_data(float *array, int place, int count, char *current, float divider) static inline Eina_Bool _read_ply_header(char *map, Evas_Model_Load_Save_Header *header) { - eina_init(); - Eina_Bool reading_vertices = EINA_TRUE, check_next_char = EINA_FALSE; int vertex_lines, triangles = 0, vertices_in_current_face = 0; char **helping_pointer; diff --git a/src/modules/evas/model_savers/obj/evas_model_save_obj.c b/src/modules/evas/model_savers/obj/evas_model_save_obj.c index 09e5c72..2b5db86 100644 --- a/src/modules/evas/model_savers/obj/evas_model_save_obj.c +++ b/src/modules/evas/model_savers/obj/evas_model_save_obj.c @@ -94,7 +94,6 @@ _write_obj_vertex_data(FILE *file, Eina_Stringshare *str, *cur_str, *cur_index; unsigned short cur_hu; - eina_init(); Eina_Hash *vb; #define WRITE_OBJ_VERTEX_DATA(name, num, format) \ if (header.existence_of_##name) \ @@ -126,7 +125,6 @@ _write_obj_vertex_data(FILE *file, WRITE_OBJ_VERTEX_DATA(tex_coords, 2, "vt") WRITE_OBJ_VERTEX_DATA(normals, 3, "vn") #undef WRITE_OBJ_VERTEX_DATA - eina_shutdown(); } static inline void -- 2.7.4