From bdcf3c3504566fd61c42b06ee41cae5c074c3c03 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 7 Dec 2021 13:44:52 +0800 Subject: [PATCH] Cancel xwidget progress timer when buffer is killed * lisp/xwidget.el (xwidget-webkit-buffer-kill): New function. (xwidget-webkit-mode): Add `xwidget-webkit-buffer-kill' to `kill-buffer-hook'. (bug#52344) --- lisp/xwidget.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index cf4396fec2d..ce9839ebd34 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -409,6 +409,11 @@ If N is omitted or nil, scroll backwards by one char." (with-current-buffer (xwidget-buffer xwidget) (force-mode-line-update))) +(defun xwidget-webkit-buffer-kill () + "Clean up an xwidget-webkit buffer before it is killed." + (when (timerp xwidget-webkit--progress-update-timer) + (cancel-timer xwidget-webkit--progress-update-timer))) + (defun xwidget-webkit-callback (xwidget xwidget-event-type) "Callback for xwidgets. XWIDGET instance, XWIDGET-EVENT-TYPE depends on the originating xwidget." @@ -479,6 +484,7 @@ If non-nil, plugins are enabled. Otherwise, disabled." (define-derived-mode xwidget-webkit-mode special-mode "xwidget-webkit" "Xwidget webkit view mode." (setq buffer-read-only t) + (add-hook 'kill-buffer-hook #'xwidget-webkit-buffer-kill) (setq-local tool-bar-map xwidget-webkit-tool-bar-map) (setq-local bookmark-make-record-function #'xwidget-webkit-bookmark-make-record) -- 2.39.2