ecore: fix shutdown when using system module.
authorCedric BAIL <cedric.bail@samsung.com>
Mon, 23 Dec 2013 02:58:17 +0000 (11:58 +0900)
committerCedric BAIL <cedric.bail@samsung.com>
Mon, 23 Dec 2013 02:58:17 +0000 (11:58 +0900)
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
src/tests/ecore/ecore_test_ecore.c

index d9c194c..5870206 100644 (file)
@@ -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();
index f3b260a..08a00e2 100644 (file)
@@ -42,6 +42,7 @@ START_TEST(ecore_test_ecore_init)
    fail_if(ret < 1);
 
    ret = ecore_shutdown();
+   fail_if(ret != 0);
 }
 END_TEST