simplify evas_init() and evas_shutdown() a bit

SVN revision: 42956
This commit is contained in:
Vincent Torri 2009-10-08 06:25:09 +00:00
parent 9e8c44052d
commit 7902ce1bb7
1 changed files with 33 additions and 30 deletions

View File

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