nsxiv64b885b
Fix navigating from last to previous image over invalid files
+5 −4
2 files changed
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20171024 | |
| 1 | + | VERSION = git-20171026 | |
| 2 | 2 | ||
| 3 | 3 | srcdir = . | |
| 4 | 4 | VPATH = $(srcdir) | |
| @@ -159,8 +159,8 @@ void remove_file(int n, bool manual) | |||
| 159 | 159 | memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files)); | |
| 160 | 160 | } | |
| 161 | 161 | filecnt--; | |
| 162 | − | if (fileidx >= filecnt) | |
| 163 | − | fileidx = filecnt - 1; | |
| 162 | + | if (n < fileidx) | |
| 163 | + | fileidx--; | |
| 164 | 164 | if (n < alternate) | |
| 165 | 165 | alternate--; | |
| 166 | 166 | } | |
| @@ -290,6 +290,7 @@ end: | |||
| 290 | 290 | ||
| 291 | 291 | void load_image(int new) | |
| 292 | 292 | { | |
| 293 | + | bool prev = new < fileidx; | |
| 293 | 294 | static int current; | |
| 294 | 295 | ||
| 295 | 296 | if (new < 0 || new >= filecnt) | |
| @@ -307,7 +308,7 @@ void load_image(int new) | |||
| 307 | 308 | remove_file(new, false); | |
| 308 | 309 | if (new >= filecnt) | |
| 309 | 310 | new = filecnt - 1; | |
| 310 | − | else if (new > 0 && new < fileidx) | |
| 311 | + | else if (new > 0 && prev) | |
| 311 | 312 | new--; | |
| 312 | 313 | } | |
| 313 | 314 | files[new].flags &= ~FF_WARN; | |