all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: yantar92@posteo.net
Cc: 65678@debbugs.gnu.org
Subject: bug#65678: 30.0.50; EWW rendered errs when the EWW buffer is closed before the page gets loaded
Date: Sat, 02 Sep 2023 14:38:16 +0300	[thread overview]
Message-ID: <83cyz0ajpz.fsf@gnu.org> (raw)
In-Reply-To: <83ledp9f91.fsf@gnu.org> (message from Eli Zaretskii on Sat, 02 Sep 2023 11:00:10 +0300)

> Cc: 65678@debbugs.gnu.org
> Date: Sat, 02 Sep 2023 11:00:10 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
> I couldn't easily simulate that here (you didn't say what you do to
> "close a EWW page"), so would you please see if the change below gives
> good results?

Sorry, that patch included a thinko.  Please try the below one
instead:

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 089e481..4ddda21 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -620,46 +620,49 @@ eww-render
     (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	other threads:[~2023-09-02 11:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01 13:44 bug#65678: 30.0.50; EWW rendered errs when the EWW buffer is closed before the page gets loaded Ihor Radchenko
2023-09-02  8:00 ` Eli Zaretskii
2023-09-02 11:38   ` Eli Zaretskii [this message]
2023-09-08  8:48     ` Ihor Radchenko
2023-09-08 12:12       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83cyz0ajpz.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=65678@debbugs.gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.