summaryrefslogtreecommitdiff
path: root/kitty-graphics.el
diff options
context:
space:
mode:
authorTim Felgentreff <timfelgentreff@gmail.com>2026-04-29 09:33:44 +0200
committerTim Felgentreff <timfelgentreff@gmail.com>2026-04-29 12:01:55 +0200
commit42f0e3ef12a885e1fdf465af0547d93df692b4bc (patch)
tree3e926f8a09003e4c6445cc192eb2a998e5ba5112 /kitty-graphics.el
parent2a9c024f9e3c9fbd0835fe0bd07dc1ebd2107a6e (diff)
downloadkitty-graphics-42f0e3ef12a885e1fdf465af0547d93df692b4bc.tar.gz
Guard Sixel cleanup against nil files
kitty-gfx--sixel-cleanup can be called without a file when cleanup is routed through generic backend code. In that case the old implementation passed nil to md5 while pruning cached Sixel temp files. Make the cleanup a no-op when FILE is nil.
Diffstat (limited to 'kitty-graphics.el')
-rw-r--r--kitty-graphics.el15
1 files changed, 8 insertions, 7 deletions
diff --git a/kitty-graphics.el b/kitty-graphics.el
index d1514df..5eed0c1 100644
--- a/kitty-graphics.el
+++ b/kitty-graphics.el
@@ -860,13 +860,14 @@ Sixel has no placement IDs — erase by writing spaces over the region."
(defun kitty-gfx--sixel-cleanup (file _image-id)
"Cleanup Sixel resources for FILE."
- (remhash file kitty-gfx--sixel-cache)
- ;; Remove cached sixel encodings for this file
- (dolist (temp-file kitty-gfx--sixel-temp-files)
- (when (string-match-p (regexp-quote (md5 file)) temp-file)
- (kitty-gfx--log "sixel-cleanup: deleting %s" temp-file)
- (ignore-errors (delete-file temp-file))
- (setq kitty-gfx--sixel-temp-files (delete temp-file kitty-gfx--sixel-temp-files)))))
+ (when file
+ (remhash file kitty-gfx--sixel-cache)
+ ;; Remove cached sixel encodings for this file
+ (dolist (temp-file kitty-gfx--sixel-temp-files)
+ (when (string-match-p (regexp-quote (md5 file)) temp-file)
+ (kitty-gfx--log "sixel-cleanup: deleting %s" temp-file)
+ (ignore-errors (delete-file temp-file))
+ (setq kitty-gfx--sixel-temp-files (delete temp-file kitty-gfx--sixel-temp-files))))))
(defun kitty-gfx--sixel-cleanup-all ()
"Cleanup all Sixel resources.