aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2014-02-25 16:59:14 -0500
committerGlenn Morris2014-02-25 16:59:14 -0500
commitf086804c36438f83ed2f12f5dba635c2e5d34561 (patch)
tree5478e2a4bbf3a7763e85dc81d11ea15c6cfe436d
parentc107155e622fc0ae9a9ed1a3fc0ef6b1b084d6a2 (diff)
downloademacs-f086804c36438f83ed2f12f5dba635c2e5d34561.tar.gz
emacs-f086804c36438f83ed2f12f5dba635c2e5d34561.zip
* lisp/image.el (image-animate, image-animate-timeout): Stop animating images
in dead buffers. Fixes: debbugs:16878
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/image.el50
2 files changed, 29 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c4ae355bbe5..07812f6fced 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12014-02-25 Glenn Morris <rgm@gnu.org> 12014-02-25 Glenn Morris <rgm@gnu.org>
2 2
3 * image.el (image-animate, image-animate-timeout):
4 Stop animating images in dead buffers. (Bug#16878)
5
3 * emacs-lisp/edebug.el (defmacro): Fix debug spec. (Bug#16868) 6 * emacs-lisp/edebug.el (defmacro): Fix debug spec. (Bug#16868)
4 7
5 * faces.el (tty-setup-hook, tty-run-terminal-initialization): Doc fixes. 8 * 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."
662 (when animation 662 (when animation
663 (if (setq timer (image-animate-timer image)) 663 (if (setq timer (image-animate-timer image))
664 (cancel-timer timer)) 664 (cancel-timer timer))
665 (plist-put (cdr image) :animate-buffer (current-buffer))
665 (run-with-timer 0.2 nil 'image-animate-timeout 666 (run-with-timer 0.2 nil 'image-animate-timeout
666 image (or index 0) (car animation) 667 image (or index 0) (car animation)
667 0 limit)))) 668 0 limit))))
@@ -726,30 +727,31 @@ The minimum delay between successive frames is `image-minimum-frame-delay'.
726 727
727If the image has a non-nil :speed property, it acts as a multiplier 728If the image has a non-nil :speed property, it acts as a multiplier
728for the animation speed. A negative value means to animate in reverse." 729for the animation speed. A negative value means to animate in reverse."
729 (image-show-frame image n t) 730 (when (buffer-live-p (plist-get (cdr image) :animate-buffer))
730 (let* ((speed (image-animate-get-speed image)) 731 (image-show-frame image n t)
731 (time (float-time)) 732 (let* ((speed (image-animate-get-speed image))
732 (animation (image-multi-frame-p image)) 733 (time (float-time))
733 ;; Subtract off the time we took to load the image from the 734 (animation (image-multi-frame-p image))
734 ;; stated delay time. 735 ;; Subtract off the time we took to load the image from the
735 (delay (max (+ (* (or (cdr animation) image-default-frame-delay) 736 ;; stated delay time.
736 (/ 1 (abs speed))) 737 (delay (max (+ (* (or (cdr animation) image-default-frame-delay)
737 time (- (float-time))) 738 (/ 1 (abs speed)))
738 image-minimum-frame-delay)) 739 time (- (float-time)))
739 done) 740 image-minimum-frame-delay))
740 (setq n (if (< speed 0) 741 done)
741 (1- n) 742 (setq n (if (< speed 0)
742 (1+ n))) 743 (1- n)
743 (if limit 744 (1+ n)))
744 (cond ((>= n count) (setq n 0)) 745 (if limit
745 ((< n 0) (setq n (1- count)))) 746 (cond ((>= n count) (setq n 0))
746 (and (or (>= n count) (< n 0)) (setq done t))) 747 ((< n 0) (setq n (1- count))))
747 (setq time-elapsed (+ delay time-elapsed)) 748 (and (or (>= n count) (< n 0)) (setq done t)))
748 (if (numberp limit) 749 (setq time-elapsed (+ delay time-elapsed))
749 (setq done (>= time-elapsed limit))) 750 (if (numberp limit)
750 (unless done 751 (setq done (>= time-elapsed limit)))
751 (run-with-timer delay nil 'image-animate-timeout 752 (unless done
752 image n count time-elapsed limit)))) 753 (run-with-timer delay nil 'image-animate-timeout
754 image n count time-elapsed limit)))))
753 755
754 756
755(defvar imagemagick-types-inhibit) 757(defvar imagemagick-types-inhibit)