From 018af5b44cf2b1026e4d4ba529dd37be8f85fc90 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 23 Jan 2009 21:08:35 +0000 Subject: [PATCH] Fix image cache shutdown. we should just remove entries pending preload from the cache being shutdown, not all of them. this is untested as it is hard to force this situation, but should be more correct than the previous. SVN revision: 38747 --- legacy/evas/src/lib/cache/evas_cache_image.c | 37 +++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/legacy/evas/src/lib/cache/evas_cache_image.c b/legacy/evas/src/lib/cache/evas_cache_image.c index 89aabfa59a..d2d155d312 100644 --- a/legacy/evas/src/lib/cache/evas_cache_image.c +++ b/legacy/evas/src/lib/cache/evas_cache_image.c @@ -499,6 +499,21 @@ _evas_cache_image_free_cb(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const voi return 1; } +#ifdef BUILD_ASYNC_PRELOAD +static void +_evas_cache_image_entry_clear_preloaders(Image_Entry *ie) +{ + while (ie->targets) + { + Evas_Cache_Target *t = ie->targets; + ie->targets = (Evas_Cache_Target *) + eina_inlist_remove(EINA_INLIST_GET(ie->targets), + EINA_INLIST_GET(ie->targets)); + free(t); + } +} +#endif + EAPI void evas_cache_image_shutdown(Evas_Cache_Image *cache) { @@ -515,22 +530,20 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache) pthread_mutex_lock(&mutex); if (running) { - while (preload) + Eina_Inlist *l, *l_next; + for (l = preload; l != NULL; l = l_next) { - Evas_Cache_Preload *tmp = (Evas_Cache_Preload *)preload; + Evas_Cache_Preload *tmp = (Evas_Cache_Preload *)l; Image_Entry *ie = tmp->ie; - while (ie->targets) - { - Evas_Cache_Target *t = ie->targets; - ie->targets = (Evas_Cache_Target *) - eina_inlist_remove(EINA_INLIST_GET(ie->targets), - EINA_INLIST_GET(ie->targets)); - free(t); - } + l_next = l->next; - preload = eina_inlist_remove(preload, preload); - free(tmp); + if (ie->cache != cache) + continue; + + preload = eina_inlist_remove(preload, l); + _evas_cache_image_entry_clear_preloaders(ie); + free(l); } } pthread_mutex_unlock(&mutex);