emotion: add infra to properly track pending object on shutdown.
authorcedric <cedric>
Tue, 3 Jul 2012 01:58:13 +0000 (01:58 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 3 Jul 2012 01:58:13 +0000 (01:58 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/emotion@73176 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/bin/emotion_test_main.c
src/lib/emotion_main.c
src/lib/emotion_private.h

index beb9c64..ae4b10a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,3 +25,7 @@
 2012-06-19  Cedric Bail
 
        * Sync rendering with Ecore_Animator.
+
+2012-06-03  Cedric Bail
+
+       * Track pending object for proper shutdown.
diff --git a/NEWS b/NEWS
index cb4d5af..5fffba7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Additions:
        - Add support for "playback_started" callback to generic player.
        - Implement SPU switch for generic/vlc.
        - Sync rendering with Ecore_Animator.
+       - Track pending object for proper shutdown.
 
 Fixes:
        - build out of tree.
index 93c80fd..80446ac 100644 (file)
@@ -719,6 +719,8 @@ main(int argc, char **argv)
    evas_font_cache_set(evas, 1 * 1024 * 1024);
    evas_font_path_append(evas, PACKAGE_DATA_DIR"/data/fonts");
 
+   emotion_init();
+
    bg_setup();
 
    for (; args < argc; args++)
@@ -729,6 +731,8 @@ main(int argc, char **argv)
    ecore_main_loop_begin();
 
    main_signal_exit(NULL, 0, NULL);
+
+   emotion_shutdown();
    ecore_evas_free(ecore_evas);
    ecore_evas_shutdown();
    edje_shutdown();
index 74c6eeb..52b1baa 100644 (file)
@@ -49,6 +49,7 @@ void *alloca (size_t);
 #include "emotion_private.h"
 
 static Emotion_Version _version = { VMAJ, VMIN, VMIC, VREV };
+static int emotion_pending_objects = 0;
 EAPI Emotion_Version *emotion_version = &_version;
 
 EAPI int EMOTION_WEBCAM_UPDATE = 0;
@@ -343,6 +344,8 @@ emotion_init(void)
 
    if (_emotion_webcams_count++) return EINA_TRUE;
 
+   ecore_init();
+
    snprintf(buffer, 4096, "%s/emotion.cfg", PACKAGE_DATA_DIR);
    _emotion_webcams_file = eet_open(buffer, EET_FILE_MODE_READ);
    if (_emotion_webcams_file)
@@ -382,6 +385,7 @@ EAPI Eina_Bool
 emotion_shutdown(void)
 {
    Emotion_Webcam *ew;
+   double start;
 
    if (_emotion_webcams_count <= 0)
      {
@@ -415,6 +419,17 @@ emotion_shutdown(void)
    eeze_shutdown();
 #endif
 
+   start = ecore_time_get();
+   while (emotion_pending_objects && ecore_time_get() - start < 0.5)
+     ecore_main_loop_iterate();
+
+   if (emotion_pending_objects)
+     {
+        EINA_LOG_ERR("There is still %i Emotion pipeline running", emotion_pending_objects);
+     }
+
+   ecore_shutdown();
+
    return EINA_TRUE;
 }
 
@@ -455,3 +470,15 @@ emotion_webcam_custom_get(const char *device)
 
    return NULL;
 }
+
+EAPI void
+_emotion_pending_object_ref(void)
+{
+   emotion_pending_objects++;
+}
+
+EAPI void
+_emotion_pending_object_unref(void)
+{
+   emotion_pending_objects--;
+}
index 4f9458f..62801fc 100644 (file)
@@ -128,4 +128,7 @@ EAPI Eina_Bool _emotion_module_unregister(const char *name);
 
 EAPI const char *emotion_webcam_custom_get(const char *device);
 
+EAPI void _emotion_pending_object_ref(void);
+EAPI void _emotion_pending_object_unref(void);
+
 #endif