summaryrefslogtreecommitdiff
path: root/lisp/image.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2014-02-25 16:59:14 -0500
committerGlenn Morris <rgm@gnu.org>2014-02-25 16:59:14 -0500
commitf086804c36438f83ed2f12f5dba635c2e5d34561 (patch)
tree5478e2a4bbf3a7763e85dc81d11ea15c6cfe436d /lisp/image.el
parentc107155e622fc0ae9a9ed1a3fc0ef6b1b084d6a2 (diff)
downloademacs-f086804c36438f83ed2f12f5dba635c2e5d34561.tar.gz
* lisp/image.el (image-animate, image-animate-timeout): Stop animating images
in dead buffers. Fixes: debbugs:16878
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el50
1 files changed, 26 insertions, 24 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 29cb06f0e03..ef39fa7909f 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -662,6 +662,7 @@ number, play until that number of seconds has elapsed."
(when animation
(if (setq timer (image-animate-timer image))
(cancel-timer timer))
+ (plist-put (cdr image) :animate-buffer (current-buffer))
(run-with-timer 0.2 nil 'image-animate-timeout
image (or index 0) (car animation)
0 limit))))
@@ -726,30 +727,31 @@ The minimum delay between successive frames is `image-minimum-frame-delay'.
If the image has a non-nil :speed property, it acts as a multiplier
for the animation speed. A negative value means to animate in reverse."
- (image-show-frame image n t)
- (let* ((speed (image-animate-get-speed image))
- (time (float-time))
- (animation (image-multi-frame-p image))
- ;; Subtract off the time we took to load the image from the
- ;; stated delay time.
- (delay (max (+ (* (or (cdr animation) image-default-frame-delay)
- (/ 1 (abs speed)))
- time (- (float-time)))
- image-minimum-frame-delay))
- done)
- (setq n (if (< speed 0)
- (1- n)
- (1+ n)))
- (if limit
- (cond ((>= n count) (setq n 0))
- ((< n 0) (setq n (1- count))))
- (and (or (>= n count) (< n 0)) (setq done t)))
- (setq time-elapsed (+ delay time-elapsed))
- (if (numberp limit)
- (setq done (>= time-elapsed limit)))
- (unless done
- (run-with-timer delay nil 'image-animate-timeout
- image n count time-elapsed limit))))
+ (when (buffer-live-p (plist-get (cdr image) :animate-buffer))
+ (image-show-frame image n t)
+ (let* ((speed (image-animate-get-speed image))
+ (time (float-time))
+ (animation (image-multi-frame-p image))
+ ;; Subtract off the time we took to load the image from the
+ ;; stated delay time.
+ (delay (max (+ (* (or (cdr animation) image-default-frame-delay)
+ (/ 1 (abs speed)))
+ time (- (float-time)))
+ image-minimum-frame-delay))
+ done)
+ (setq n (if (< speed 0)
+ (1- n)
+ (1+ n)))
+ (if limit
+ (cond ((>= n count) (setq n 0))
+ ((< n 0) (setq n (1- count))))
+ (and (or (>= n count) (< n 0)) (setq done t)))
+ (setq time-elapsed (+ delay time-elapsed))
+ (if (numberp limit)
+ (setq done (>= time-elapsed limit)))
+ (unless done
+ (run-with-timer delay nil 'image-animate-timeout
+ image n count time-elapsed limit)))))
(defvar imagemagick-types-inhibit)