image: Use imlib2's image cache

This makes imlib add images loaded from files to its image cache again. That way
we avoid loading the same image again and again (e.g. if you cycle through the
list layouts all the layout icons are loaded).

To not reintroduce FS#651 (fixed in 2dadce9b), we call
imlib_image_set_changes_on_disk(). This causes two stat() calls if the same file
is loaded again to check if the file's timestamps changed which is still less
expensive than loading the whole image again.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Uli Schlachter 2009-12-12 13:50:40 +01:00 committed by Julien Danjou
parent da53940dd9
commit a038f7667c
1 changed files with 7 additions and 1 deletions

View File

@ -285,12 +285,18 @@ image_new_from_file(lua_State *L, const char *filename)
if(!filename)
return 0;
if(!(imimage = imlib_load_image_without_cache(filename)))
if(!(imimage = imlib_load_image(filename)))
{
warn("cannot load image %s", filename);
return 0;
}
/* Make imlib check if the file changed on disk if it's later opened by the
* same file name again before using its cache.
*/
imlib_context_set_image(imimage);
imlib_image_set_changes_on_disk();
image = image_new(L);
image->image = imimage;