org-display-inline-remove-overlay: Do better job clearing images from cache

* lisp/org.el (org-display-inline-remove-overlay): Force remove
overlay images from Emacs image cache when un-displaying inline image
overlays.  This change should: (1) slightly improve Emacs memory usage
when the number of inline images is large; (2) Clear images from cache
every time Emacs removes the overlay for any
reason.  (`org-display-inline-remove-overlay' is used in
overlay 'modification-hooks.)
This commit is contained in:
Ihor Radchenko 2022-12-11 12:13:44 +03:00
parent 954a95ec5f
commit 41a8666c09
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 4 additions and 0 deletions

View File

@ -16399,6 +16399,10 @@ buffer boundaries with possible narrowing."
"Remove inline-display overlay if a corresponding region is modified."
(when (and ov after)
(delete ov org-inline-image-overlays)
;; Clear image from cache to avoid image not updating upon
;; changing on disk. See Emacs bug#59902.
(when (overlay-get ov 'org-image-overlay)
(image-flush (overlay-get ov 'display)))
(delete-overlay ov)))
(defun org-remove-inline-images (&optional beg end)