diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2017-11-06 13:49:18 -0800 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2017-11-07 16:08:39 -0800 |
commit | ee65414ef6b75a61044227a9a4ab10201cee787d (patch) | |
tree | a9a3aa18f6677e4953d4ea252e69966e441fc7d6 | |
parent | 3d72cb8da38d014a75a2e2908ee37b33676f38b5 (diff) | |
download | efl-ee65414ef6b75a61044227a9a4ab10201cee787d.tar.gz |
ecore: introduce ecore_init_ex/ecore_shutdown_ex to propagate argc,argv properly.
-rw-r--r-- | src/lib/ecore/Ecore_Common.h | 26 | ||||
-rw-r--r-- | src/lib/ecore/ecore.c | 28 | ||||
-rw-r--r-- | src/lib/elementary/efl_general.h | 12 | ||||
-rw-r--r-- | src/lib/elementary/elm_main.c | 15 |
4 files changed, 70 insertions, 11 deletions
diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h index 999fb8633f..6102341446 100644 --- a/src/lib/ecore/Ecore_Common.h +++ b/src/lib/ecore/Ecore_Common.h @@ -62,6 +62,32 @@ EAPI int ecore_init(void); */ EAPI int ecore_shutdown(void); +/** + * This function will propagate the events on the main loop. So you + * should call ecore_init() first, then register your callback on + * @c EFL_LOOP_EVENT_ARGUMENTS and finally call ecore_init_ex(). + * + * Once you are shuting down your program, you should symetrically + * call ecore_shutdown_ex(). + */ +EAPI unsigned int ecore_init_ex(int argc, char **argv); + +/** + * Shuts down connections, signal handlers sockets etc. + * + * @return @c 0 if ecore shuts down, greater than @c 0 otherwise. + * This function shuts down all things set up in ecore_init_ex() and cleans + * up all event queues, handlers, filters, timers, idlers, idle enterers/exiters + * etc. set up after ecore_init_ex() was called. + * + * Do not call this function from any callback that may be called from the main + * loop, as the main loop will then fall over and not function properly. + * + * Note: This function should be called in symetric to ecore_init_ex() + */ +EAPI unsigned int ecore_shutdown_ex(void); + + #ifdef EFL_BETA_API_SUPPORT /** * @brief Inform EFL of the version this application was built for. diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index 5ac30d64b2..2e6644e422 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -489,6 +489,31 @@ ecore_shutdown(void) return _ecore_init_count; } +static unsigned int _ecore_init_ex = 0; + +EAPI unsigned int +ecore_init_ex(int argc, char **argv) +{ + if (_ecore_init_ex++ != 0) return _ecore_init_ex; + + ecore_init(); + ecore_loop_arguments_send(argc - 1, + (argc > 1) ? ((const char **) argv + 1) : NULL); + ecore_app_args_set(argc, (const char**) argv); + + return _ecore_init_ex; +} + +EAPI unsigned int +ecore_shutdown_ex(void) +{ + if (--_ecore_init_ex != 0) return _ecore_init_ex; + + ecore_shutdown(); + + return _ecore_init_ex; +} + struct _Ecore_Fork_Cb { Ecore_Cb func; @@ -543,7 +568,7 @@ ecore_fork_reset(void) { Eina_List *l, *ln; Ecore_Fork_Cb *fcb; - + eina_main_loop_define(); eina_lock_take(&_thread_safety); @@ -555,7 +580,6 @@ ecore_fork_reset(void) eina_lock_release(&_thread_safety); // should this be done withing the eina lock stuff? - fork_cbs_walking++; EINA_LIST_FOREACH(fork_cbs, l, fcb) { diff --git a/src/lib/elementary/efl_general.h b/src/lib/elementary/efl_general.h index e1e81a2287..9d7171b05f 100644 --- a/src/lib/elementary/efl_general.h +++ b/src/lib/elementary/efl_general.h @@ -37,11 +37,15 @@ int real__; \ _efl_startup_time = ecore_time_unix_get(); \ _EFL_APP_VERSION_SET(); \ - elm_init(argc, argv); \ + ecore_init(); \ efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); \ + ecore_init_ex(argc, argv); \ + elm_init(argc, argv); \ ret__ = efl_loop_begin(ecore_main_loop_get()); \ real__ = efl_loop_exit_code_process(ret__); \ elm_shutdown(); \ + ecore_shutdown_ex(); \ + ecore_shutdown(); \ return real__; \ } @@ -57,11 +61,15 @@ int real__; \ _efl_startup_time = ecore_time_unix_get(); \ _EFL_APP_VERSION_SET(); \ - elm_init(argc, argv); \ + ecore_init(); \ efl_event_callback_array_add(ecore_main_loop_get(), _efl_main_ex(), NULL); \ + ecore_init_ex(argc, argv); \ + elm_init(argc, argv); \ ret__ = efl_loop_begin(ecore_main_loop_get()); \ real__ = efl_loop_exit_code_process(ret__); \ elm_shutdown(); \ + ecore_shutdown_ex(); \ + ecore_shutdown(); \ return real__; \ } diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c index 3b089583ee..551df529c1 100644 --- a/src/lib/elementary/elm_main.c +++ b/src/lib/elementary/elm_main.c @@ -406,9 +406,6 @@ elm_init(int argc, char **argv) elm_quicklaunch_init(argc, argv); elm_quicklaunch_sub_init(argc, argv); - ecore_loop_arguments_send(argc - 1, - (argc > 1) ? ((const char **)argv + 1) : NULL); - _prefix_shutdown(); system_handlers[0] = @@ -752,7 +749,6 @@ elm_quicklaunch_init(int argc, #ifdef HAVE_ELEMENTARY_EMAP emap_init(); #endif - ecore_app_args_set(argc, (const char **)argv); memset(_elm_policies, 0, sizeof(_elm_policies)); if (!ELM_EVENT_POLICY_CHANGED) @@ -812,7 +808,6 @@ elm_quicklaunch_sub_init(int argc, if (!quicklaunch_on) { - ecore_app_args_set(argc, (const char **)argv); ecore_evas_init(); // FIXME: check errors edje_init(); elm_color_class_init(); @@ -824,6 +819,8 @@ elm_quicklaunch_sub_init(int argc, ecore_con_url_init(); _elm_prefs_initted = _elm_prefs_init(); _elm_ews_wm_init(); + + ecore_init_ex(argc, argv); } return _elm_sub_init_count; } @@ -1189,7 +1186,6 @@ elm_quicklaunch_fork(int argc, _elm_appname = strdup(ecore_file_file_get(argv[0])); #ifdef SEMI_BROKEN_QUICKLAUNCH - ecore_app_args_set(argc, (const char **)argv); evas_init(); _elm_module_init(); _elm_config_sub_init(); @@ -1233,7 +1229,6 @@ elm_quicklaunch_fork(int argc, setsid(); if (chdir(cwd) != 0) perror("could not chdir"); - ecore_app_args_set(argc, (const char **)argv); if (_elm_config->atspi_mode != ELM_ATSPI_MODE_OFF) _elm_atspi_bridge_init(); @@ -1247,15 +1242,21 @@ elm_quicklaunch_fork(int argc, { efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, qre_main, NULL); } + + ecore_init_ex(argc, argv); + ret = efl_loop_exit_code_process(efl_loop_begin(ecore_main_loop_get())); elm_shutdown(); exit(ret); } else { + ecore_init_ex(argc, argv); + ret = qr_main(argc, argv); exit(ret); } + return EINA_TRUE; #else return EINA_FALSE; |