From 4b622523eb22d3cc19fde5cc685da55dcc6a9967 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 14 Dec 2009 10:24:08 +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 --- image.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/image.c b/image.c index d4d8c6082..603af059e 100644 --- a/image.c +++ b/image.c @@ -282,12 +282,18 @@ image_new_from_file(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(globalconf.L); image->image = imimage;