Fix file list indexes when deleting last image

Fixes issue #331
This commit is contained in:
Bert Münnich 2018-12-29 18:48:23 +01:00
parent 0bf3265430
commit 674f69f2c9
1 changed files with 3 additions and 3 deletions

6
main.c
View File

@ -155,11 +155,11 @@ void remove_file(int n, bool manual)
memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files)); memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files));
} }
filecnt--; filecnt--;
if (n < fileidx) if (fileidx > n || fileidx == filecnt)
fileidx--; fileidx--;
if (n < alternate) if (alternate > n || alternate == filecnt)
alternate--; alternate--;
if (n < markidx) if (markidx > n || markidx == filecnt)
markidx--; markidx--;
} }