From a038f7667c1bc517ea9b549e50994f7a0b848fd9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 12 Dec 2009 13:50:40 +0100 Subject: [PATCH] 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 Signed-off-by: Julien Danjou --- objects/image.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/objects/image.c b/objects/image.c index 65485547f..0cc995081 100644 --- a/objects/image.c +++ b/objects/image.c @@ -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;