simplify evas_init() and evas_shutdown() a bit
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 8 Oct 2009 06:25:09 +0000 (06:25 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 8 Oct 2009 06:25:09 +0000 (06:25 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@42956 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_main.c

index a83a767..c5349f7 100644 (file)
@@ -2,7 +2,7 @@
 #include "evas_private.h"
 #include "evas_cs.h"
 
-static int initcount = 0;
+static int _evas_init_count = 0;
 int _evas_log_dom_global = -1;
 /**
  * Initialize Evas
@@ -18,36 +18,39 @@ int _evas_log_dom_global = -1;
 EAPI int
 evas_init(void)
 {
-   if (initcount == 0)
+   if (++_evas_init_count != 1)
+     return _evas_init_count;
+
+   if (!eina_init())
+     return 0;
+
+   _evas_log_dom_global = eina_log_domain_register("evas_main",EVAS_DEFAULT_LOG_COLOR);
+   if (_evas_log_dom_global < 0)
      {
-       if (!eina_init())
-         return 0;
-       _evas_log_dom_global = eina_log_domain_register("evas_main",EVAS_DEFAULT_LOG_COLOR);
-       if(_evas_log_dom_global < 0)
-         {
-           fprintf(stderr,"Error: Evas could not create a default log domain\n");
-           eina_shutdown();
-           return 0;
-         }
-       evas_module_init();
+       fprintf(stderr,"Error: Evas could not create a default log domain\n");
+       goto shutdown_eina;
+     }
+
+   evas_module_init();
 #ifdef BUILD_ASYNC_EVENTS
-       if (!evas_async_events_init())
-         goto shutdown_module;
+   if (!evas_async_events_init())
+     goto shutdown_module;
 #endif
 #ifdef EVAS_CSERVE
-        if (getenv("EVAS_CSERVE")) evas_cserve_init();
+   if (getenv("EVAS_CSERVE")) evas_cserve_init();
 #endif
-     }
-   return ++initcount;
+
+   return _evas_init_count;
 
 #ifdef BUILD_ASYNC_EVENTS
  shutdown_module:
    evas_module_shutdown();
    eina_log_domain_unregister(_evas_log_dom_global);
+#endif
+ shutdown_eina:
    eina_shutdown();
 
    return 0;
-#endif
 }
 
 /**
@@ -65,22 +68,22 @@ evas_init(void)
 EAPI int
 evas_shutdown(void)
 {
-   initcount--;
-   if (initcount == 0)
-     {
+   if (--_evas_init_count != 0)
+     return _evas_init_count;
+
 #ifdef EVAS_CSERVE
-        if (getenv("EVAS_CSERVE")) evas_cserve_shutdown();
+   if (getenv("EVAS_CSERVE")) evas_cserve_shutdown();
 #endif
 #ifdef BUILD_ASYNC_EVENTS
-       evas_async_events_shutdown();
+   evas_async_events_shutdown();
 #endif
-       evas_font_dir_cache_free();
-       evas_common_shutdown();
-       evas_module_shutdown();
-       eina_log_domain_unregister(_evas_log_dom_global);
-       eina_shutdown();
-     }
-   return initcount;
+   evas_font_dir_cache_free();
+   evas_common_shutdown();
+   evas_module_shutdown();
+   eina_log_domain_unregister(_evas_log_dom_global);
+   eina_shutdown();
+
+   return _evas_init_count;
 }
 
 /**