diff --git a/legacy/ephysics/src/lib/ephysics_main.cpp b/legacy/ephysics/src/lib/ephysics_main.cpp index 09ad9ce60a..e486f89ad1 100644 --- a/legacy/ephysics/src/lib/ephysics_main.cpp +++ b/legacy/ephysics/src/lib/ephysics_main.cpp @@ -12,8 +12,30 @@ extern "C" { #endif int _ephysics_log_dom = -1; +static int _ephysics_dom_count = 0; static int _ephysics_init_count = 0; +void +ephysics_dom_count_inc(void) +{ + _ephysics_dom_count++; +} + +void +ephysics_dom_count_dec(void) +{ + _ephysics_dom_count--; + if (_ephysics_dom_count) + return; + + INF("EPhysics shutdown"); + + eina_log_domain_unregister(_ephysics_log_dom); + _ephysics_log_dom = -1; + + eina_shutdown(); +} + EAPI int ephysics_init() { @@ -45,6 +67,7 @@ ephysics_init() goto no_world; } + ephysics_dom_count_inc(); INF("EPhysics initialized"); return _ephysics_init_count; @@ -66,14 +89,8 @@ ephysics_shutdown() return _ephysics_init_count; ephysics_world_shutdown(); - - INF("EPhysics shutdown"); - - eina_log_domain_unregister(_ephysics_log_dom); - _ephysics_log_dom = -1; - ecore_shutdown(); - eina_shutdown(); + ephysics_dom_count_dec(); return _ephysics_init_count; } diff --git a/legacy/ephysics/src/lib/ephysics_private.h b/legacy/ephysics/src/lib/ephysics_private.h index 2024073b32..08d9af6d0e 100644 --- a/legacy/ephysics/src/lib/ephysics_private.h +++ b/legacy/ephysics/src/lib/ephysics_private.h @@ -97,6 +97,10 @@ struct _EPhysics_Body { extern int _ephysics_log_dom; +/* Main */ +void ephysics_dom_count_inc(void); +void ephysics_dom_count_dec(void); + /* World */ int ephysics_world_init(void); int ephysics_world_shutdown(void); diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp index b77b2841b6..fd7492804e 100644 --- a/legacy/ephysics/src/lib/ephysics_world.cpp +++ b/legacy/ephysics/src/lib/ephysics_world.cpp @@ -340,6 +340,7 @@ _ephysics_world_free(EPhysics_World *world) free(world); INF("World %p deleted.", world); + ephysics_dom_count_dec(); } static Eina_Bool @@ -717,6 +718,7 @@ ephysics_world_new(void) if (!_anim_simulate) _anim_simulate = ecore_animator_add(_simulate_worlds, NULL); + ephysics_dom_count_inc(); INF("World %p added.", world); return world;