forked from enlightenment/efl
and actively remove images when they are KNOWN to have been removed from disk
or the cached copies have 0 refs and are too old (thus wasting cache space). SVN revision: 31243
This commit is contained in:
parent
c28878389d
commit
f23f99bf84
|
@ -151,8 +151,24 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
|
|||
hkey = alloca(sizeof (char) * size);
|
||||
snprintf(hkey, size, format, file, key, lo->scale_down_by, lo->dpi, lo->w, lo->h);
|
||||
|
||||
if (stat(file, &st) < 0) return NULL;
|
||||
/* FIXME: Handle timestamp correctly. */
|
||||
if (stat(file, &st) < 0)
|
||||
{
|
||||
im = evas_hash_find(cache->inactiv, hkey);
|
||||
if (im)
|
||||
{
|
||||
cache->lru = evas_object_list_remove(cache->lru, im);
|
||||
cache->inactiv = evas_hash_del(cache->inactiv, im->cache_key, im);
|
||||
cache->usage -= cache->func.mem_size_get(im);
|
||||
if (im->cache_key)
|
||||
{
|
||||
evas_stringshare_del(im->cache_key);
|
||||
im->cache_key = NULL;
|
||||
}
|
||||
cache->func.destructor(im);
|
||||
evas_common_image_delete(im);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
im = evas_hash_find(cache->activ, hkey);
|
||||
if (im)
|
||||
|
@ -172,6 +188,19 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
|
|||
cache->usage -= cache->func.mem_size_get(im);
|
||||
goto on_ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache->lru = evas_object_list_remove(cache->lru, im);
|
||||
cache->inactiv = evas_hash_del(cache->inactiv, im->cache_key, im);
|
||||
cache->usage -= cache->func.mem_size_get(im);
|
||||
if (im->cache_key)
|
||||
{
|
||||
evas_stringshare_del(im->cache_key);
|
||||
im->cache_key = NULL;
|
||||
}
|
||||
cache->func.destructor(im);
|
||||
evas_common_image_delete(im);
|
||||
}
|
||||
}
|
||||
|
||||
im = evas_common_image_new();
|
||||
|
|
Loading…
Reference in New Issue