emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7572620da29: Avoid errors in EWW when EWW is killed


From: Eli Zaretskii
Subject: master 7572620da29: Avoid errors in EWW when EWW is killed
Date: Fri, 8 Sep 2023 08:12:11 -0400 (EDT)

branch: master
commit 7572620da292d5e4ab5ca9a24cd9b4b853f035eb
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid errors in EWW when EWW is killed
    
    * lisp/net/eww.el (eww-render): Don't signal errors if the page
    being rendered was closed.  (Bug#65678)
---
 lisp/net/eww.el | 83 ++++++++++++++++++++++++++++++---------------------------
 1 file changed, 43 insertions(+), 40 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 089e481ead2..4ddda216afc 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -620,46 +620,49 @@ The renaming scheme is performed in accordance with
     (let ((redirect (plist-get status :redirect)))
       (when redirect
         (setq url redirect)))
-    (with-current-buffer buffer
-      ;; Save the https peer status.
-      (plist-put eww-data :peer (plist-get status :peer))
-      ;; Make buffer listings more informative.
-      (setq list-buffers-directory url)
-      ;; Let the URL library have a handle to the current URL for
-      ;; referer purposes.
-      (setq url-current-lastloc (url-generic-parse-url url)))
-    (unwind-protect
-       (progn
-         (cond
-           ((and eww-use-external-browser-for-content-type
-                 (string-match-p eww-use-external-browser-for-content-type
-                                 (car content-type)))
-            (erase-buffer)
-            (insert "<title>Unsupported content type</title>")
-            (insert (format "<h1>Content-type %s is unsupported</h1>"
-                            (car content-type)))
-            (insert (format "<a href=%S>Direct link to the document</a>"
-                            url))
-            (goto-char (point-min))
-           (eww-display-html charset url nil point buffer encode))
-          ((eww-html-p (car content-type))
-           (eww-display-html charset url nil point buffer encode))
-          ((equal (car content-type) "application/pdf")
-           (eww-display-pdf))
-          ((string-match-p "\\`image/" (car content-type))
-           (eww-display-image buffer))
-          (t
-           (eww-display-raw buffer (or encode charset 'utf-8))))
-         (with-current-buffer buffer
-           (plist-put eww-data :url url)
-           (eww--after-page-change)
-           (setq eww-history-position 0)
-           (and last-coding-system-used
-                (set-buffer-file-coding-system last-coding-system-used))
-           (run-hooks 'eww-after-render-hook)
-            ;; Enable undo again so that undo works in text input
-            ;; boxes.
-            (setq buffer-undo-list nil)))
+    (when (buffer-live-p buffer)
+      (with-current-buffer buffer
+        ;; Save the https peer status.
+        (plist-put eww-data :peer (plist-get status :peer))
+        ;; Make buffer listings more informative.
+        (setq list-buffers-directory url)
+        ;; Let the URL library have a handle to the current URL for
+        ;; referer purposes.
+        (setq url-current-lastloc (url-generic-parse-url url)))
+      (unwind-protect
+         (progn
+           (cond
+             ((and eww-use-external-browser-for-content-type
+                   (string-match-p eww-use-external-browser-for-content-type
+                                   (car content-type)))
+              (erase-buffer)
+              (insert "<title>Unsupported content type</title>")
+              (insert (format "<h1>Content-type %s is unsupported</h1>"
+                              (car content-type)))
+              (insert (format "<a href=%S>Direct link to the document</a>"
+                              url))
+              (goto-char (point-min))
+             (eww-display-html charset url nil point buffer encode))
+            ((eww-html-p (car content-type))
+             (eww-display-html charset url nil point buffer encode))
+            ((equal (car content-type) "application/pdf")
+             (eww-display-pdf))
+            ((string-match-p "\\`image/" (car content-type))
+             (eww-display-image buffer))
+            (t
+             (eww-display-raw buffer (or encode charset 'utf-8))))
+           (with-current-buffer buffer
+             (plist-put eww-data :url url)
+             (eww--after-page-change)
+             (setq eww-history-position 0)
+             (and last-coding-system-used
+                  (set-buffer-file-coding-system last-coding-system-used))
+             (run-hooks 'eww-after-render-hook)
+              ;; Enable undo again so that undo works in text input
+              ;; boxes.
+              (setq buffer-undo-list nil)))
+        (kill-buffer data-buffer)))
+    (unless (buffer-live-p buffer)
       (kill-buffer data-buffer))))
 
 (defun eww-parse-headers ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]