From da508cf4bd437f8fd9a06fce33f6e62590e1e4d9 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 20 Nov 2021 14:30:12 +0800 Subject: [PATCH] Use `xwidget-live-p' inside `xwidget-at'. It should no longer be possible for Lisp code to abuse internal xwidget state, or cause crashes with killed xwidgets and such, so the pedantic checking done in this function is no longer necessary. (In fact, it is even wrong, as it won't catch killed xwidgets.) * lisp/xwidget.el (xwidget-at): Use `xwidget-live-p'. --- lisp/xwidget.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 89f81bb8164..91580efa49a 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -58,6 +58,7 @@ (declare-function xwidget-webkit-back-forward-list "xwidget.c" (xwidget &optional limit)) (declare-function xwidget-webkit-estimated-load-progress "xwidget.c" (xwidget)) (declare-function xwidget-webkit-set-cookie-storage-file "xwidget.c" (xwidget file)) +(declare-function xwidget-live-p "xwidget.c" (xwidget)) (defgroup xwidget nil "Displaying native widgets in Emacs buffers." @@ -77,12 +78,9 @@ This returns the result of `make-xwidget'." (defun xwidget-at (pos) "Return xwidget at POS." - ;; TODO this function is a bit tedious because the C layer isn't well - ;; protected yet and xwidgetp apparently doesn't work yet. (let* ((disp (get-text-property pos 'display)) - (xw (car (cdr (cdr disp))))) - ;;(if (xwidgetp xw) xw nil) - (if (equal 'xwidget (car disp)) xw))) + (xw (car (cdr (cdr disp))))) + (when (xwidget-live-p xw) xw))) -- 2.39.2