From f9080e9bc08367b2bdc8779975dd7d7945f36859 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Tue, 27 Jan 2026 15:13:15 +0100 Subject: [PATCH] Always unset lisp_data when freeing images Historically only the GIF code did this (since it stores animation metadata in lisp_data), and recently the WebP code followed suit. The benefit of clearing lisp_data is not 100% clear (to me: bug#66221#41), but it probably can't hurt, so do it unconditionally for all image types to simplify conditional compilation and avoid warnings (bug#80266). * src/image.c (image_clear_image): Set lisp_data to nil. [HAVE_GIF || HAVE_WEBP] (gif_clear_image): [HAVE_IMAGEMAGICK] (imagemagick_clear_image): Remove, replacing all uses with image_clear_image. --- src/image.c | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/src/image.c b/src/image.c index 5a4bc3024c3..ccbf5db028f 100644 --- a/src/image.c +++ b/src/image.c @@ -2131,6 +2131,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags) static void image_clear_image (struct frame *f, struct image *img) { + img->lisp_data = Qnil; block_input (); image_clear_image_1 (f, img, (CLEAR_IMAGE_PIXMAP @@ -9653,24 +9654,6 @@ static const struct image_keyword gif_format[GIF_LAST] = {":background", IMAGE_STRING_OR_NIL_VALUE, 0} }; -#endif - -#if defined HAVE_GIF || defined HAVE_WEBP - -/* Free X resources of GIF image IMG which is used on frame F. - Also used by other image types. */ - -static void -gif_clear_image (struct frame *f, struct image *img) -{ - img->lisp_data = Qnil; - image_clear_image (f, img); -} - -#endif /* defined HAVE_GIF || defined HAVE_WEBP */ - -#if defined (HAVE_GIF) - /* Return true if OBJECT is a valid GIF image specification. */ static bool @@ -10900,15 +10883,6 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] = {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} }; -/* Free X resources of imagemagick image IMG which is used on frame F. */ - -static void -imagemagick_clear_image (struct frame *f, - struct image *img) -{ - image_clear_image (f, img); -} - /* Return true if OBJECT is a valid IMAGEMAGICK image specification. Do this by calling parse_image_spec and supplying the keywords that identify the IMAGEMAGICK format. */ @@ -12954,7 +12928,7 @@ static struct image_type const image_types[] = #endif #ifdef HAVE_IMAGEMAGICK { SYMBOL_INDEX (Qimagemagick), imagemagick_image_p, imagemagick_load, - imagemagick_clear_image }, + image_clear_image }, #endif #ifdef HAVE_RSVG { SYMBOL_INDEX (Qsvg), svg_image_p, svg_load, image_clear_image, @@ -12965,7 +12939,7 @@ static struct image_type const image_types[] = IMAGE_TYPE_INIT (init_png_functions) }, #endif #if defined HAVE_GIF - { SYMBOL_INDEX (Qgif), gif_image_p, gif_load, gif_clear_image, + { SYMBOL_INDEX (Qgif), gif_image_p, gif_load, image_clear_image, IMAGE_TYPE_INIT (init_gif_functions) }, #endif #if defined HAVE_TIFF @@ -12982,7 +12956,7 @@ static struct image_type const image_types[] = IMAGE_TYPE_INIT (init_xpm_functions) }, #endif #if defined HAVE_WEBP - { SYMBOL_INDEX (Qwebp), webp_image_p, webp_load, gif_clear_image, + { SYMBOL_INDEX (Qwebp), webp_image_p, webp_load, image_clear_image, IMAGE_TYPE_INIT (init_webp_functions) }, #endif { SYMBOL_INDEX (Qxbm), xbm_image_p, xbm_load, image_clear_image },