summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-26 21:13:46 +0900
committerHermet Park <hermetpark@gmail.com>2018-07-26 21:13:46 +0900
commit69fdec545e527a03c462dfc285a50a77e296fc12 (patch)
tree4d60e60a1cd7176f4a7924a7e0242d6a34018403
parentff5cc5d988006616406a65b8119ea6499b7b8bf6 (diff)
elm: handle all failure cases with error messages in init
Summary: fix T7021 Depends on D6678 Reviewers: Hermet Reviewed By: Hermet Subscribers: cedric, #committers Tags: #efl Maniphest Tasks: T7021 Differential Revision: https://phab.enlightenment.org/D6679
-rw-r--r--src/lib/elementary/elm_main.c92
1 files changed, 66 insertions, 26 deletions
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index 8eac4fe40f..425310c18e 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -390,11 +390,12 @@ elm_init(int argc, char **argv)
390{ 390{
391 _elm_init_count++; 391 _elm_init_count++;
392 if (_elm_init_count > 1) return _elm_init_count; 392 if (_elm_init_count > 1) return _elm_init_count;
393 elm_quicklaunch_init(argc, argv ? argv : (char**) bcargv); 393 EINA_SAFETY_ON_FALSE_RETURN_VAL(elm_quicklaunch_init(argc, argv ? argv : (char**) bcargv), --_elm_init_count);
394 elm_quicklaunch_sub_init(argc, argv ? argv : (char**) bcargv); 394 EINA_SAFETY_ON_FALSE_GOTO(elm_quicklaunch_sub_init(argc, argv ? argv : (char**) bcargv), shutdown_ql);
395 395
396 _prefix_shutdown(); 396 _prefix_shutdown();
397 397
398 /* this is fine if it fails */
398 _elm_clouseau_load(); 399 _elm_clouseau_load();
399 400
400 system_handlers[0] = 401 system_handlers[0] =
@@ -419,6 +420,9 @@ elm_init(int argc, char **argv)
419 _elm_startup_time = _efl_startup_time; 420 _elm_startup_time = _efl_startup_time;
420 421
421 return _elm_init_count; 422 return _elm_init_count;
423shutdown_ql:
424 elm_quicklaunch_shutdown();
425 return --_elm_init_count;
422} 426}
423 427
424EAPI int 428EAPI int
@@ -724,22 +728,18 @@ elm_quicklaunch_init(int argc EINA_UNUSED,
724 _elm_ql_init_count++; 728 _elm_ql_init_count++;
725 if (_elm_ql_init_count > 1) return _elm_ql_init_count; 729 if (_elm_ql_init_count > 1) return _elm_ql_init_count;
726 _use_build_config = !!getenv("EFL_RUN_IN_TREE"); 730 _use_build_config = !!getenv("EFL_RUN_IN_TREE");
727 eina_init(); 731 EINA_SAFETY_ON_FALSE_GOTO(eina_init(), fail_eina);
728 _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE); 732 _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE);
729 if (!_elm_log_dom) 733 EINA_SAFETY_ON_TRUE_GOTO(_elm_log_dom < 0, fail_eina_log);
730 {
731 EINA_LOG_ERR("could not register elementary log domain.");
732 _elm_log_dom = EINA_LOG_DOMAIN_GLOBAL;
733 }
734 734
735 eet_init(); 735 EINA_SAFETY_ON_FALSE_GOTO(eet_init(), fail_eet);
736 ecore_init(); 736 EINA_SAFETY_ON_FALSE_GOTO(ecore_init(), fail_ecore);
737 ecore_event_init(); 737 EINA_SAFETY_ON_FALSE_GOTO(ecore_event_init(), fail_ecore_event);
738 edje_init(); 738 EINA_SAFETY_ON_FALSE_GOTO(edje_init(), fail_edje);
739 eio_init(); 739 EINA_SAFETY_ON_FALSE_GOTO(eio_init(), fail_eio);
740 740
741#ifdef HAVE_ELEMENTARY_EMAP 741#ifdef HAVE_ELEMENTARY_EMAP
742 emap_init(); 742 EINA_SAFETY_ON_FALSE_GOTO(emap_init(), fail_emap);
743#endif 743#endif
744 744
745 memset(_elm_policies, 0, sizeof(_elm_policies)); 745 memset(_elm_policies, 0, sizeof(_elm_policies));
@@ -747,8 +747,7 @@ elm_quicklaunch_init(int argc EINA_UNUSED,
747 ELM_EVENT_PROCESS_BACKGROUND = ecore_event_type_new(); 747 ELM_EVENT_PROCESS_BACKGROUND = ecore_event_type_new();
748 ELM_EVENT_PROCESS_FOREGROUND = ecore_event_type_new(); 748 ELM_EVENT_PROCESS_FOREGROUND = ecore_event_type_new();
749 749
750 if (!ecore_file_init()) 750 EINA_SAFETY_ON_FALSE_GOTO(ecore_file_init(), fail_ecore_file);
751 ERR("Elementary cannot init ecore_file");
752 751
753 _elm_exit_handler = 752 _elm_exit_handler =
754 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL); 753 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL);
@@ -781,6 +780,28 @@ elm_quicklaunch_init(int argc EINA_UNUSED,
781 if (quicklaunch_on) 780 if (quicklaunch_on)
782 _elm_init_count++; 781 _elm_init_count++;
783 return _elm_ql_init_count; 782 return _elm_ql_init_count;
783
784fail_ecore_file:
785#ifdef HAVE_ELEMENTARY_EMAP
786 emap_shutdown();
787fail_emap:
788#endif
789 eio_shutdown();
790fail_eio:
791 edje_shutdown();
792fail_edje:
793 ecore_event_shutdown();
794fail_ecore_event:
795 ecore_shutdown();
796fail_ecore:
797 eet_shutdown();
798fail_eet:
799 eina_log_domain_unregister(_elm_log_dom);
800 _elm_log_dom = -1;
801fail_eina_log:
802 eina_shutdown();
803fail_eina:
804 return --_elm_ql_init_count;
784} 805}
785 806
786EAPI int 807EAPI int
@@ -793,19 +814,34 @@ elm_quicklaunch_sub_init(int argc,
793 814
794 if (!quicklaunch_on) 815 if (!quicklaunch_on)
795 { 816 {
796 ecore_evas_init(); // FIXME: check errors 817 EINA_SAFETY_ON_FALSE_GOTO(ecore_init_ex(argc, argv), ql_sub_ecore);
818 EINA_SAFETY_ON_FALSE_GOTO(ecore_evas_init(), ql_sub_ee);
797 elm_color_class_init(); 819 elm_color_class_init();
798 _elm_module_init(); 820 _elm_module_init();
799 _elm_config_sub_init(); 821 _elm_config_sub_init();
800 ecore_imf_init(); 822 EINA_SAFETY_ON_FALSE_GOTO(ecore_imf_init(), ql_sub_imf);
801 ecore_con_init(); 823 EINA_SAFETY_ON_FALSE_GOTO(ecore_con_init(), ql_sub_ecore_con);
802 ecore_con_url_init(); 824 EINA_SAFETY_ON_FALSE_GOTO(ecore_con_url_init(), ql_sub_ecore_con_url);
803 _elm_prefs_initted = _elm_prefs_init(); 825 _elm_prefs_initted = _elm_prefs_init();
804 _elm_ews_wm_init(); 826 EINA_SAFETY_ON_FALSE_GOTO(_elm_ews_wm_init(), ql_sub_ews);;
805
806 ecore_init_ex(argc, argv);
807 } 827 }
808 return _elm_sub_init_count; 828 return _elm_sub_init_count;
829ql_sub_ews:
830 if (_elm_prefs_initted) _elm_prefs_shutdown();
831 ecore_con_url_shutdown();
832ql_sub_ecore_con_url:
833 ecore_con_shutdown();
834ql_sub_ecore_con:
835 ecore_imf_shutdown();
836ql_sub_imf:
837 ecore_evas_shutdown();
838 _elm_module_shutdown();
839 _elm_config_sub_shutdown();
840ql_sub_ee:
841 ecore_shutdown_ex();
842ql_sub_ecore:
843 _elm_config_shutdown();
844 return --_elm_sub_init_count;
809} 845}
810 846
811EAPI int 847EAPI int
@@ -877,7 +913,7 @@ elm_quicklaunch_shutdown(void)
877 ecore_shutdown(); 913 ecore_shutdown();
878 eet_shutdown(); 914 eet_shutdown();
879 915
880 if ((_elm_log_dom > -1) && (_elm_log_dom != EINA_LOG_DOMAIN_GLOBAL)) 916 if (_elm_log_dom > -1)
881 { 917 {
882 eina_log_domain_unregister(_elm_log_dom); 918 eina_log_domain_unregister(_elm_log_dom);
883 _elm_log_dom = -1; 919 _elm_log_dom = -1;
@@ -1206,12 +1242,16 @@ elm_quicklaunch_fallback(int argc,
1206{ 1242{
1207 int ret; 1243 int ret;
1208 char cwd[PATH_MAX]; 1244 char cwd[PATH_MAX];
1209 elm_quicklaunch_init(argc, argv); 1245 /* return nonzero on failure */
1210 elm_quicklaunch_sub_init(argc, argv); 1246 EINA_SAFETY_ON_FALSE_RETURN_VAL(elm_quicklaunch_init(argc, argv), 1);
1247 EINA_SAFETY_ON_FALSE_GOTO(elm_quicklaunch_sub_init(argc, argv), fallback_ql);
1211 elm_quicklaunch_prepare(argc, argv, getcwd(cwd, sizeof(cwd))); 1248 elm_quicklaunch_prepare(argc, argv, getcwd(cwd, sizeof(cwd)));
1212 ret = qr_main(argc, argv); 1249 ret = qr_main(argc, argv);
1213 exit(ret); 1250 exit(ret);
1214 return ret; 1251 return ret;
1252fallback_ql:
1253 elm_quicklaunch_shutdown();
1254 return 1;
1215} 1255}
1216 1256
1217EAPI char * 1257EAPI char *