summaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-05-12 07:39:11 +0000
committerPo Lu <luangruo@yahoo.com>2022-05-12 07:42:33 +0000
commit89c6e412dd6bcb3a8e5e90d9a52cf6f6fd233776 (patch)
treea0adc7a8843259cda881a56dc24137c522eec30e /src/image.c
parent0e5623b491cb4158d8055b9c2ee7963fee8c75de (diff)
downloademacs-89c6e412dd6bcb3a8e5e90d9a52cf6f6fd233776.tar.gz
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.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c22
1 files changed, 21 insertions, 1 deletions
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);