Krolyxon
Commit 19b4719

Branches

Refs →

nsxiv19b4719

fix: thumbnail leak when removing the last file (#423)

bf6c062 tried to fixed the thumbnail leak, but it was done inside a
`if (n+1 < filecnt)` branch, meaning the thumbnail was still leaking
away whenever the last file was removed.

we need to unload the thumb regardless of whether it's in the middle or
not. this bug was caught due to the recent `assert`s that were added in
01f3cf2.
Author
NRK
Date
2023-03-04 07:01 +0000
Parent
8f0322c
Commit
19b47192f21939b46a8f46d131c31f138aaa3b33

+2 −4

1 file changed

  1. M main.c +2 −4
M main.c View
@@ -195,13 +195,11 @@ void remove_file(int n, bool manual)
195195 if (files[n].path != files[n].name)
196196 free((void*) files[n].path);
197197 free((void*) files[n].name);
198+ if (tns.thumbs != NULL)
199+ tns_unload(&tns, n);
198200
199201 if (n + 1 < filecnt) {
200202 if (tns.thumbs != NULL) {
201− if (tns.thumbs[n].im != NULL) {
202− imlib_context_set_image(tns.thumbs[n].im);
203− imlib_free_image_and_decache();
204− }
205203 memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) *
206204 sizeof(*tns.thumbs));
207205 memset(tns.thumbs + filecnt - 1, 0, sizeof(*tns.thumbs));