diff options
author | NRK <nrk@disroot.org> | 2023-07-02 15:16:55 +0200 |
---|---|---|
committer | NRK <nrk@disroot.org> | 2023-09-21 00:54:41 +0200 |
commit | 69d4957a92030bf89323d9174c45263727483de4 (patch) | |
tree | bdf9a284455fe6e643e200ea30a52233bd06d42d | |
parent | d19924f288f049228dfc691ccdf13721be3c98f9 (diff) | |
download | nsxiv-69d4957a92030bf89323d9174c45263727483de4.tar.zst |
remove faulty assertions
these assertions did not hold true in practice when the underlying file
ends up changing during load.
-rw-r--r-- | image.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -490,9 +490,22 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) bool has_alpha; imlib_context_set_image(m->cnt < 1 ? blank : m->frames[m->cnt - 1].im); - if ((canvas = imlib_clone_image()) == NULL || - (frame = imlib_load_image_frame(file->path, n)) == NULL) + canvas = imlib_clone_image(); + if ((frame = imlib_load_image_frame(file->path, n)) != NULL) { + imlib_context_set_image(frame); + imlib_image_set_changes_on_disk(); /* see img_load() for rationale */ + imlib_image_get_frame_info(&finfo); + } + /* NOTE: the underlying file can end up changing during load. + * so check if frame_count, w, h are all still the same or not. + */ + if (canvas == NULL || frame == NULL || finfo.frame_count != (int)fcnt || + finfo.canvas_w != img->w || finfo.canvas_h != img->h) { + if (frame != NULL) { + imlib_context_set_image(frame); + imlib_free_image(); + } if (canvas != NULL) { imlib_context_set_image(canvas); imlib_free_image(); @@ -501,11 +514,6 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) break; } - imlib_context_set_image(frame); - imlib_image_set_changes_on_disk(); /* see img_load() for rationale */ - imlib_image_get_frame_info(&finfo); - assert(finfo.frame_count == (int)fcnt); - assert(finfo.canvas_w == img->w && finfo.canvas_h == img->h); sx = finfo.frame_x; sy = finfo.frame_y; sw = finfo.frame_w; |