diff options
| author | Lars Ingebrigtsen | 2016-05-04 01:37:01 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-05-04 01:37:01 +0200 |
| commit | 9ec81c5a6e12d9fec56767307d6072546b5a4dc2 (patch) | |
| tree | fa54445b85e4e270f73646c6c771147c4c26bd10 | |
| parent | 3a788d7a4126e9b7038140ee95fe7b5b9d8fe65c (diff) | |
| download | emacs-9ec81c5a6e12d9fec56767307d6072546b5a4dc2.tar.gz emacs-9ec81c5a6e12d9fec56767307d6072546b5a4dc2.zip | |
Add an animation sanity check
* lisp/image.el (image-multi-frame-p): Give up on animations
if it seems like they are too slow (bug#23431).
| -rw-r--r-- | lisp/image.el | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/image.el b/lisp/image.el index 2ae642a3e32..57cfc4e7062 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -731,7 +731,7 @@ number, play until that number of seconds has elapsed." | |||
| 731 | (plist-put (cdr image) :animate-buffer (current-buffer)) | 731 | (plist-put (cdr image) :animate-buffer (current-buffer)) |
| 732 | (run-with-timer 0.2 nil 'image-animate-timeout | 732 | (run-with-timer 0.2 nil 'image-animate-timeout |
| 733 | image (or index 0) (car animation) | 733 | image (or index 0) (car animation) |
| 734 | 0 limit)))) | 734 | 0 limit (+ (float-time) 0.2))))) |
| 735 | 735 | ||
| 736 | (defun image-animate-timer (image) | 736 | (defun image-animate-timer (image) |
| 737 | "Return the animation timer for image IMAGE." | 737 | "Return the animation timer for image IMAGE." |
| @@ -780,7 +780,7 @@ multiplication factor for the current value." | |||
| 780 | ;; hence we need to call image-multi-frame-p to return it. | 780 | ;; hence we need to call image-multi-frame-p to return it. |
| 781 | ;; But it also returns count, so why do we bother passing that as an | 781 | ;; But it also returns count, so why do we bother passing that as an |
| 782 | ;; argument? | 782 | ;; argument? |
| 783 | (defun image-animate-timeout (image n count time-elapsed limit) | 783 | (defun image-animate-timeout (image n count time-elapsed limit target-time) |
| 784 | "Display animation frame N of IMAGE. | 784 | "Display animation frame N of IMAGE. |
| 785 | N=0 refers to the initial animation frame. | 785 | N=0 refers to the initial animation frame. |
| 786 | COUNT is the total number of frames in the animation. | 786 | COUNT is the total number of frames in the animation. |
| @@ -793,7 +793,11 @@ The minimum delay between successive frames is `image-minimum-frame-delay'. | |||
| 793 | 793 | ||
| 794 | If the image has a non-nil :speed property, it acts as a multiplier | 794 | If the image has a non-nil :speed property, it acts as a multiplier |
| 795 | for the animation speed. A negative value means to animate in reverse." | 795 | for the animation speed. A negative value means to animate in reverse." |
| 796 | (when (buffer-live-p (plist-get (cdr image) :animate-buffer)) | 796 | (when (and (buffer-live-p (plist-get (cdr image) :animate-buffer)) |
| 797 | ;; Delayed more than two seconds more than expected. | ||
| 798 | (when (> (- (float-time) target-time) 2) | ||
| 799 | (message "Stopping animation; animation possibly too big") | ||
| 800 | nil)) | ||
| 797 | (image-show-frame image n t) | 801 | (image-show-frame image n t) |
| 798 | (let* ((speed (image-animate-get-speed image)) | 802 | (let* ((speed (image-animate-get-speed image)) |
| 799 | (time (float-time)) | 803 | (time (float-time)) |
| @@ -817,7 +821,8 @@ for the animation speed. A negative value means to animate in reverse." | |||
| 817 | (setq done (>= time-elapsed limit))) | 821 | (setq done (>= time-elapsed limit))) |
| 818 | (unless done | 822 | (unless done |
| 819 | (run-with-timer delay nil 'image-animate-timeout | 823 | (run-with-timer delay nil 'image-animate-timeout |
| 820 | image n count time-elapsed limit))))) | 824 | image n count time-elapsed limit |
| 825 | (+ (float-time) delay)))))) | ||
| 821 | 826 | ||
| 822 | 827 | ||
| 823 | (defvar imagemagick-types-inhibit) | 828 | (defvar imagemagick-types-inhibit) |