From: Glenn Morris Date: Tue, 25 Feb 2014 21:59:14 +0000 (-0500) Subject: * lisp/image.el (image-animate, image-animate-timeout): Stop animating images X-Git-Tag: emacs-24.3.90~357^2~7^2~14 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f086804c36438f83ed2f12f5dba635c2e5d34561;p=emacs.git * lisp/image.el (image-animate, image-animate-timeout): Stop animating images in dead buffers. Fixes: debbugs:16878 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c4ae355bbe5..07812f6fced 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2014-02-25 Glenn Morris + * image.el (image-animate, image-animate-timeout): + Stop animating images in dead buffers. (Bug#16878) + * emacs-lisp/edebug.el (defmacro): Fix debug spec. (Bug#16868) * faces.el (tty-setup-hook, tty-run-terminal-initialization): Doc fixes. 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)