summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-11-06 13:49:18 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-11-07 16:08:39 -0800
commitee65414ef6b75a61044227a9a4ab10201cee787d (patch)
treea9a3aa18f6677e4953d4ea252e69966e441fc7d6
parent3d72cb8da38d014a75a2e2908ee37b33676f38b5 (diff)
ecore: introduce ecore_init_ex/ecore_shutdown_ex to propagate argc,argv properly.
-rw-r--r--src/lib/ecore/Ecore_Common.h26
-rw-r--r--src/lib/ecore/ecore.c28
-rw-r--r--src/lib/elementary/efl_general.h12
-rw-r--r--src/lib/elementary/elm_main.c15
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);
62 */ 62 */
63EAPI int ecore_shutdown(void); 63EAPI int ecore_shutdown(void);
64 64
65/**
66 * This function will propagate the events on the main loop. So you
67 * should call ecore_init() first, then register your callback on
68 * @c EFL_LOOP_EVENT_ARGUMENTS and finally call ecore_init_ex().
69 *
70 * Once you are shuting down your program, you should symetrically
71 * call ecore_shutdown_ex().
72 */
73EAPI unsigned int ecore_init_ex(int argc, char **argv);
74
75/**
76 * Shuts down connections, signal handlers sockets etc.
77 *
78 * @return @c 0 if ecore shuts down, greater than @c 0 otherwise.
79 * This function shuts down all things set up in ecore_init_ex() and cleans
80 * up all event queues, handlers, filters, timers, idlers, idle enterers/exiters
81 * etc. set up after ecore_init_ex() was called.
82 *
83 * Do not call this function from any callback that may be called from the main
84 * loop, as the main loop will then fall over and not function properly.
85 *
86 * Note: This function should be called in symetric to ecore_init_ex()
87 */
88EAPI unsigned int ecore_shutdown_ex(void);
89
90
65#ifdef EFL_BETA_API_SUPPORT 91#ifdef EFL_BETA_API_SUPPORT
66/** 92/**
67 * @brief Inform EFL of the version this application was built for. 93 * @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)
489 return _ecore_init_count; 489 return _ecore_init_count;
490} 490}
491 491
492static unsigned int _ecore_init_ex = 0;
493
494EAPI unsigned int
495ecore_init_ex(int argc, char **argv)
496{
497 if (_ecore_init_ex++ != 0) return _ecore_init_ex;
498
499 ecore_init();
500 ecore_loop_arguments_send(argc - 1,
501 (argc > 1) ? ((const char **) argv + 1) : NULL);
502 ecore_app_args_set(argc, (const char**) argv);
503
504 return _ecore_init_ex;
505}
506
507EAPI unsigned int
508ecore_shutdown_ex(void)
509{
510 if (--_ecore_init_ex != 0) return _ecore_init_ex;
511
512 ecore_shutdown();
513
514 return _ecore_init_ex;
515}
516
492struct _Ecore_Fork_Cb 517struct _Ecore_Fork_Cb
493{ 518{
494 Ecore_Cb func; 519 Ecore_Cb func;
@@ -543,7 +568,7 @@ ecore_fork_reset(void)
543{ 568{
544 Eina_List *l, *ln; 569 Eina_List *l, *ln;
545 Ecore_Fork_Cb *fcb; 570 Ecore_Fork_Cb *fcb;
546 571
547 eina_main_loop_define(); 572 eina_main_loop_define();
548 eina_lock_take(&_thread_safety); 573 eina_lock_take(&_thread_safety);
549 574
@@ -555,7 +580,6 @@ ecore_fork_reset(void)
555 eina_lock_release(&_thread_safety); 580 eina_lock_release(&_thread_safety);
556 581
557 // should this be done withing the eina lock stuff? 582 // should this be done withing the eina lock stuff?
558
559 fork_cbs_walking++; 583 fork_cbs_walking++;
560 EINA_LIST_FOREACH(fork_cbs, l, fcb) 584 EINA_LIST_FOREACH(fork_cbs, l, fcb)
561 { 585 {
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 @@
37 int real__; \ 37 int real__; \
38 _efl_startup_time = ecore_time_unix_get(); \ 38 _efl_startup_time = ecore_time_unix_get(); \
39 _EFL_APP_VERSION_SET(); \ 39 _EFL_APP_VERSION_SET(); \
40 elm_init(argc, argv); \ 40 ecore_init(); \
41 efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); \ 41 efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); \
42 ecore_init_ex(argc, argv); \
43 elm_init(argc, argv); \
42 ret__ = efl_loop_begin(ecore_main_loop_get()); \ 44 ret__ = efl_loop_begin(ecore_main_loop_get()); \
43 real__ = efl_loop_exit_code_process(ret__); \ 45 real__ = efl_loop_exit_code_process(ret__); \
44 elm_shutdown(); \ 46 elm_shutdown(); \
47 ecore_shutdown_ex(); \
48 ecore_shutdown(); \
45 return real__; \ 49 return real__; \
46 } 50 }
47 51
@@ -57,11 +61,15 @@
57 int real__; \ 61 int real__; \
58 _efl_startup_time = ecore_time_unix_get(); \ 62 _efl_startup_time = ecore_time_unix_get(); \
59 _EFL_APP_VERSION_SET(); \ 63 _EFL_APP_VERSION_SET(); \
60 elm_init(argc, argv); \ 64 ecore_init(); \
61 efl_event_callback_array_add(ecore_main_loop_get(), _efl_main_ex(), NULL); \ 65 efl_event_callback_array_add(ecore_main_loop_get(), _efl_main_ex(), NULL); \
66 ecore_init_ex(argc, argv); \
67 elm_init(argc, argv); \
62 ret__ = efl_loop_begin(ecore_main_loop_get()); \ 68 ret__ = efl_loop_begin(ecore_main_loop_get()); \
63 real__ = efl_loop_exit_code_process(ret__); \ 69 real__ = efl_loop_exit_code_process(ret__); \
64 elm_shutdown(); \ 70 elm_shutdown(); \
71 ecore_shutdown_ex(); \
72 ecore_shutdown(); \
65 return real__; \ 73 return real__; \
66 } 74 }
67 75
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)
406 elm_quicklaunch_init(argc, argv); 406 elm_quicklaunch_init(argc, argv);
407 elm_quicklaunch_sub_init(argc, argv); 407 elm_quicklaunch_sub_init(argc, argv);
408 408
409 ecore_loop_arguments_send(argc - 1,
410 (argc > 1) ? ((const char **)argv + 1) : NULL);
411
412 _prefix_shutdown(); 409 _prefix_shutdown();
413 410
414 system_handlers[0] = 411 system_handlers[0] =
@@ -752,7 +749,6 @@ elm_quicklaunch_init(int argc,
752#ifdef HAVE_ELEMENTARY_EMAP 749#ifdef HAVE_ELEMENTARY_EMAP
753 emap_init(); 750 emap_init();
754#endif 751#endif
755 ecore_app_args_set(argc, (const char **)argv);
756 752
757 memset(_elm_policies, 0, sizeof(_elm_policies)); 753 memset(_elm_policies, 0, sizeof(_elm_policies));
758 if (!ELM_EVENT_POLICY_CHANGED) 754 if (!ELM_EVENT_POLICY_CHANGED)
@@ -812,7 +808,6 @@ elm_quicklaunch_sub_init(int argc,
812 808
813 if (!quicklaunch_on) 809 if (!quicklaunch_on)
814 { 810 {
815 ecore_app_args_set(argc, (const char **)argv);
816 ecore_evas_init(); // FIXME: check errors 811 ecore_evas_init(); // FIXME: check errors
817 edje_init(); 812 edje_init();
818 elm_color_class_init(); 813 elm_color_class_init();
@@ -824,6 +819,8 @@ elm_quicklaunch_sub_init(int argc,
824 ecore_con_url_init(); 819 ecore_con_url_init();
825 _elm_prefs_initted = _elm_prefs_init(); 820 _elm_prefs_initted = _elm_prefs_init();
826 _elm_ews_wm_init(); 821 _elm_ews_wm_init();
822
823 ecore_init_ex(argc, argv);
827 } 824 }
828 return _elm_sub_init_count; 825 return _elm_sub_init_count;
829} 826}
@@ -1189,7 +1186,6 @@ elm_quicklaunch_fork(int argc,
1189 _elm_appname = strdup(ecore_file_file_get(argv[0])); 1186 _elm_appname = strdup(ecore_file_file_get(argv[0]));
1190 1187
1191#ifdef SEMI_BROKEN_QUICKLAUNCH 1188#ifdef SEMI_BROKEN_QUICKLAUNCH
1192 ecore_app_args_set(argc, (const char **)argv);
1193 evas_init(); 1189 evas_init();
1194 _elm_module_init(); 1190 _elm_module_init();
1195 _elm_config_sub_init(); 1191 _elm_config_sub_init();
@@ -1233,7 +1229,6 @@ elm_quicklaunch_fork(int argc,
1233 1229
1234 setsid(); 1230 setsid();
1235 if (chdir(cwd) != 0) perror("could not chdir"); 1231 if (chdir(cwd) != 0) perror("could not chdir");
1236 ecore_app_args_set(argc, (const char **)argv);
1237 if (_elm_config->atspi_mode != ELM_ATSPI_MODE_OFF) 1232 if (_elm_config->atspi_mode != ELM_ATSPI_MODE_OFF)
1238 _elm_atspi_bridge_init(); 1233 _elm_atspi_bridge_init();
1239 1234
@@ -1247,15 +1242,21 @@ elm_quicklaunch_fork(int argc,
1247 { 1242 {
1248 efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, qre_main, NULL); 1243 efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, qre_main, NULL);
1249 } 1244 }
1245
1246 ecore_init_ex(argc, argv);
1247
1250 ret = efl_loop_exit_code_process(efl_loop_begin(ecore_main_loop_get())); 1248 ret = efl_loop_exit_code_process(efl_loop_begin(ecore_main_loop_get()));
1251 elm_shutdown(); 1249 elm_shutdown();
1252 exit(ret); 1250 exit(ret);
1253 } 1251 }
1254 else 1252 else
1255 { 1253 {
1254 ecore_init_ex(argc, argv);
1255
1256 ret = qr_main(argc, argv); 1256 ret = qr_main(argc, argv);
1257 exit(ret); 1257 exit(ret);
1258 } 1258 }
1259
1259 return EINA_TRUE; 1260 return EINA_TRUE;
1260#else 1261#else
1261 return EINA_FALSE; 1262 return EINA_FALSE;