cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=324f4aebe8f42a1b9888760765c2f06c83c95726

commit 324f4aebe8f42a1b9888760765c2f06c83c95726
Author: Cedric BAIL <[email protected]>
Date:   Mon Dec 23 11:58:17 2013 +0900

    ecore: fix shutdown when using system module.
    
    This patch will detect how many more times ecore_init was called
    during initialization and use that as a threshold to do a clean shutdown.
    It is a necessary evil as we do have ecore module that will initialize
    eldbus that will then reinit ecore_init from within ecore_init and without
    a chance for the application to act on it.
    
    I also reenable a test to make sure we will catch earlier this kind of 
issue.
---
 src/lib/ecore/ecore.c              | 5 ++++-
 src/tests/ecore/ecore_test_ecore.c | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index d9c194c..5870206 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -58,6 +58,7 @@ Eo *_ecore_parent = NULL;
 
 static const char *_ecore_magic_string_get(Ecore_Magic m);
 static int _ecore_init_count = 0;
+static int _ecore_init_count_threshold = 0;
 int _ecore_log_dom = -1;
 int _ecore_fps_debug = 0;
 
@@ -331,6 +332,8 @@ ecore_init(void)
    if (!_no_system_modules)
      ecore_system_modules_load();
 
+   _ecore_init_count_threshold = _ecore_init_count;
+
    eina_log_timing(_ecore_log_dom,
                   EINA_LOG_STATE_STOP,
                   EINA_LOG_STATE_INIT);
@@ -375,7 +378,7 @@ ecore_shutdown(void)
           _ecore_unlock();
           return 0;
        }
-     if (--_ecore_init_count != 0)
+     if (_ecore_init_count-- != _ecore_init_count_threshold)
        goto unlock;
 
      ecore_system_modules_unload();
diff --git a/src/tests/ecore/ecore_test_ecore.c 
b/src/tests/ecore/ecore_test_ecore.c
index f3b260a..08a00e2 100644
--- a/src/tests/ecore/ecore_test_ecore.c
+++ b/src/tests/ecore/ecore_test_ecore.c
@@ -42,6 +42,7 @@ START_TEST(ecore_test_ecore_init)
    fail_if(ret < 1);
 
    ret = ecore_shutdown();
+   fail_if(ret != 0);
 }
 END_TEST
 

-- 


Reply via email to