aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-07-14 18:58:12 +0200
committerLars Ingebrigtsen2022-07-14 18:59:09 +0200
commit564f6c171eeaef4dea4b4fc2524c0b082dfbb531 (patch)
tree014595873d94947428e4a1a604f0d7602d5d51ea /lisp
parent4c542747bd40f3098a20aafe001889607f044188 (diff)
downloademacs-564f6c171eeaef4dea4b4fc2524c0b082dfbb531.tar.gz
emacs-564f6c171eeaef4dea4b4fc2524c0b082dfbb531.zip
Prune animation cache when images are no longer reachable
* lisp/image.el (image-animate-timeout): Eject cached animated images that are no longer reachable (bug#56546). * src/image.c (Fclear_image_cache): Allow specifying a cached animated image to eject. (gif_load, webp_load): Adjust what to use as the caching key -- the identity of the list itself is apparently changed by some callers.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/image.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/image.el b/lisp/image.el
index bdaaec608ef..f4f73fd31f2 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -966,9 +966,10 @@ for the animation speed. A negative value means to animate in reverse."
966 (plist-put (cdr image) :animate-tardiness 966 (plist-put (cdr image) :animate-tardiness
967 (+ (* (plist-get (cdr image) :animate-tardiness) 0.9) 967 (+ (* (plist-get (cdr image) :animate-tardiness) 0.9)
968 (float-time (time-since target-time)))) 968 (float-time (time-since target-time))))
969 (let ((buffer (plist-get (cdr image) :animate-buffer)) 969 (let* ((buffer (plist-get (cdr image) :animate-buffer))
970 (position (plist-get (cdr image) :animate-position))) 970 (position (plist-get (cdr image) :animate-position))
971 (when (and (buffer-live-p buffer) 971 (continue-animation
972 (and (buffer-live-p buffer)
972 ;; If we have a :animate-position setting, the caller 973 ;; If we have a :animate-position setting, the caller
973 ;; has requested that the animation be stopped if the 974 ;; has requested that the animation be stopped if the
974 ;; image is no longer displayed in the buffer. 975 ;; image is no longer displayed in the buffer.
@@ -985,7 +986,13 @@ for the animation speed. A negative value means to animate in reverse."
985 (or (< (plist-get (cdr image) :animate-tardiness) 2) 986 (or (< (plist-get (cdr image) :animate-tardiness) 2)
986 (progn 987 (progn
987 (message "Stopping animation; animation possibly too big") 988 (message "Stopping animation; animation possibly too big")
988 nil))) 989 nil)))))
990 (if (not continue-animation)
991 ;; Eject from the animation cache since we've decided not to
992 ;; keep updating it. This helps stop unbounded RAM usage when
993 ;; doing, for instance, `g' in an eww buffer with animated
994 ;; images.
995 (clear-image-cache nil image)
989 (let* ((time (prog1 (current-time) 996 (let* ((time (prog1 (current-time)
990 (image-show-frame image n t))) 997 (image-show-frame image n t)))
991 (speed (image-animate-get-speed image)) 998 (speed (image-animate-get-speed image))