From: Po Lu Date: Tue, 7 Dec 2021 05:44:52 +0000 (+0800) Subject: Cancel xwidget progress timer when buffer is killed X-Git-Tag: emacs-29.0.90~3610^2~22 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bdcf3c3504566fd61c42b06ee41cae5c074c3c03;p=emacs.git 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) --- 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)