aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-07-04 07:10:07 +0200
committerNRK <nrk@disroot.org>2023-09-21 00:54:41 +0200
commit80a71315de2bec9924f2e06a825d4400f2b5a4f8 (patch)
treec615d6618d4de0b11c3bbe38e480f3dc7cf9ab34
parent53a43cb38838bd65512b3b8902cc8a3ecfaaca56 (diff)
downloadnsxiv-80a71315de2bec9924f2e06a825d4400f2b5a4f8.tar.zst
fix: re-loading stale multi-frame images
4b67816 only partially fixed this issue. because imlib2's cache may not have sub-second granularity, there still exists a time-frame while the `mtime` has not yet been updated but we might be trying to reload the image due to receiving an inotify event in which case imlib2 will end up giving us the old frame. imlib2 v1.12.0 adds a function that allows us to decache any frames associated with a filename. this allows us to invalidate the cache manually instead of relying on `mtime`. but if that's not available due to older imlib2, then forcefully reload the raw frames and decache them. this has the unfortunate cost that if `mtime` *was* updated properly then we'll end up loading that image twice. fixes: https://codeberg.org/nsxiv/nsxiv/issues/456
-rw-r--r--image.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/image.c b/image.c
index a8b91a0..5e2a7a0 100644
--- a/image.c
+++ b/image.c
@@ -637,6 +637,22 @@ CLEANUP void img_close(img_t *img, bool decache)
if (img->multi.cnt > 0) {
for (i = 0; i < img->multi.cnt; i++)
img_free(img->multi.frames[i].im, decache);
+ /* NOTE: the above only decaches the "composed frames",
+ * and not the "raw frame" that's associated with the file.
+ * which leads to issues like: https://codeberg.org/nsxiv/nsxiv/issues/456
+ */
+#if HAVE_IMLIB2_MULTI_FRAME
+ #if IMLIB2_VERSION >= IMLIB2_VERSION_(1, 12, 0)
+ if (decache)
+ imlib_image_decache_file(files[fileidx].path);
+ #else /* UPGRADE: Imlib2 v1.12.0: remove this hack */
+ /* HACK: try to reload all the frames and forcefully decache them
+ * if imlib_image_decache_file() isn't available.
+ */
+ for (i = 0; decache && i < img->multi.cnt; i++)
+ img_free(imlib_load_image_frame(files[fileidx].path, i + 1), true);
+ #endif
+#endif
img->multi.cnt = 0;
img->im = NULL;
} else if (img->im != NULL) {