elementary: add a queue to postpone object destruction when necessary.
authorCedric BAIL <cedric.bail@free.fr>
Tue, 2 Apr 2019 19:30:45 +0000 (12:30 -0700)
committerYeongjong Lee <yj34.lee@samsung.com>
Wed, 24 Apr 2019 05:24:47 +0000 (14:24 +0900)
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D8540

src/lib/elementary/elm_main.c
src/lib/elementary/elm_priv.h

index 7f5d16f26d913e815de13ebd7d5a7f676a3d2e81..ad2cd535d1406a96881c780727ed31edd1f8038f 100644 (file)
@@ -46,6 +46,8 @@ static void * _accessibility_currently_highlighted_obj = NULL;
 //
 EAPI Elm_Version *elm_version = &_version;
 
+Eina_FreeQ *postponed_fq = NULL;
+
 static void
 _focus_ev_redirect_cb(void *data, const Efl_Event *ev EINA_UNUSED)
 {
@@ -790,6 +792,12 @@ elm_quicklaunch_mode_get(void)
    return quicklaunch_on;
 }
 
+static void
+_postpone_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+   eina_freeq_clear(postponed_fq);
+}
+
 EAPI int
 elm_quicklaunch_init(int    argc EINA_UNUSED,
                      char **argv)
@@ -801,6 +809,8 @@ elm_quicklaunch_init(int    argc EINA_UNUSED,
    _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE);
    EINA_SAFETY_ON_TRUE_GOTO(_elm_log_dom < 0, fail_eina_log);
 
+   postponed_fq = eina_freeq_new(EINA_FREEQ_POSTPONED);
+
    EINA_SAFETY_ON_FALSE_GOTO(eet_init(), fail_eet);
    EINA_SAFETY_ON_FALSE_GOTO(ecore_init(), fail_ecore);
    EINA_SAFETY_ON_FALSE_GOTO(ecore_event_init(), fail_ecore_event);
@@ -847,6 +857,8 @@ elm_quicklaunch_init(int    argc EINA_UNUSED,
    if (!_elm_lib_dir) _elm_lib_dir = eina_stringshare_add("/");
    if (!_property_style_ss) _property_style_ss = eina_stringshare_add("style");
 
+   efl_event_callback_add(efl_main_loop_get(), EFL_LOOP_EVENT_IDLE_EXIT, _postpone_cb, NULL);
+
    eina_log_timing(_elm_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
 
    if (quicklaunch_on)
@@ -981,6 +993,11 @@ elm_quicklaunch_shutdown(void)
    emap_shutdown();
 #endif
 
+   efl_event_callback_del(efl_main_loop_get(), EFL_LOOP_EVENT_IDLE_EXIT, _postpone_cb, NULL);
+
+   eina_freeq_free(postponed_fq);
+   postponed_fq = NULL;
+
    ecore_file_shutdown();
    eio_shutdown();
    ecore_event_shutdown();
index 9188c1a433d52a59c463a9ebe595f9be3f871a5d..8a33cdc8d627ba2e47868b20ec8288b82ae47d6c 100644 (file)
@@ -938,6 +938,8 @@ extern Eina_Stringshare *_property_style_ss;
 
 extern Eina_Bool _config_profile_lock;
 
+extern Eina_FreeQ *postponed_fq;
+
 # ifdef HAVE_ELEMENTARY_WL2
 extern Ecore_Wl2_Display *_elm_wl_display;
 # endif