diff options
author | NRK <nrk@disroot.org> | 2023-07-02 16:15:53 +0200 |
---|---|---|
committer | NRK <nrk@disroot.org> | 2023-09-21 00:54:41 +0200 |
commit | 53a43cb38838bd65512b3b8902cc8a3ecfaaca56 (patch) | |
tree | db32241dfce726a02e863c98690812c83cd1473f /thumbs.c | |
parent | 69d4957a92030bf89323d9174c45263727483de4 (diff) | |
download | nsxiv-53a43cb38838bd65512b3b8902cc8a3ecfaaca56.tar.zst |
introduce img_free()
this removes some repetitive code.
Diffstat (limited to 'thumbs.c')
-rw-r--r-- | thumbs.c | 23 |
1 files changed, 6 insertions, 17 deletions
@@ -179,12 +179,8 @@ CLEANUP void tns_free(tns_t *tns) int i; if (tns->thumbs != NULL) { - for (i = 0; i < *tns->cnt; i++) { - if (tns->thumbs[i].im != NULL) { - imlib_context_set_image(tns->thumbs[i].im); - imlib_free_image(); - } - } + for (i = 0; i < *tns->cnt; i++) + img_free(tns->thumbs[i].im, false); free(tns->thumbs); tns->thumbs = NULL; } @@ -233,12 +229,8 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only) return false; t = &tns->thumbs[n]; - - if (t->im != NULL) { - imlib_context_set_image(t->im); - imlib_free_image(); - t->im = NULL; - } + img_free(t->im, false); + t->im = NULL; if (!force) { if ((im = tns_cache_load(file->path, &force)) != NULL) { @@ -363,11 +355,8 @@ void tns_unload(tns_t *tns, int n) assert(n >= 0 && n < *tns->cnt); t = &tns->thumbs[n]; - if (t->im != NULL) { - imlib_context_set_image(t->im); - imlib_free_image(); - t->im = NULL; - } + img_free(t->im, false); + t->im = NULL; } static void tns_check_view(tns_t *tns, bool scrolled) |