#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
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
}
/**
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;
}
/**