From 89c6e412dd6bcb3a8e5e90d9a52cf6f6fd233776 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 12 May 2022 07:39:11 +0000 Subject: [PATCH] Fix searching the bitmap file path on Haiku * src/image.c (image_create_bitmap_from_file): [HAVE_HAIKU]: Look for the bitmap inside `x-bitmap-file-path' as well. --- src/image.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/image.c b/src/image.c index 0c14173d833..dfa53279927 100644 --- a/src/image.c +++ b/src/image.c @@ -750,8 +750,28 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) int fd, width, height, rc, bytes_per_line, x, y; char *contents, *data, *tmp; void *bitmap; + Lisp_Object found; - if (!STRINGP (image_find_image_fd (file, &fd))) + /* Look for an existing bitmap with the same name. */ + for (id = 0; id < dpyinfo->bitmaps_last; ++id) + { + if (dpyinfo->bitmaps[id].refcount + && dpyinfo->bitmaps[id].file + && !strcmp (dpyinfo->bitmaps[id].file, SSDATA (file))) + { + ++dpyinfo->bitmaps[id].refcount; + return id + 1; + } + } + + /* Search bitmap-file-path for the file, if appropriate. */ + if (openp (Vx_bitmap_file_path, file, Qnil, &found, + make_fixnum (R_OK), false, false) + < 0) + return -1; + + if (!STRINGP (image_find_image_fd (file, &fd)) + && !STRINGP (image_find_image_fd (found, &fd))) return -1; contents = slurp_file (fd, &size); -- 2.39.2