aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2017-10-26 22:20:39 +0200
committerBert Münnich <ber.t@posteo.de>2017-10-26 22:20:39 +0200
commit64b885b6a9fbb5522654af919a3c4ce719f11c2e (patch)
treedd000571605546895c7a541b79936123991c7c5e
parent2d34c4b9bfec8e7cafbb1a7494a5b6d79e0a5b4e (diff)
Fix navigating from last to previous image over invalid files
-rw-r--r--Makefile2
-rw-r--r--main.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 4e3390a..f14f65c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = git-20171024
+VERSION = git-20171026
srcdir = .
VPATH = $(srcdir)
diff --git a/main.c b/main.c
index 8eea930..ebe14c9 100644
--- a/main.c
+++ b/main.c
@@ -159,8 +159,8 @@ void remove_file(int n, bool manual)
memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files));
}
filecnt--;
- if (fileidx >= filecnt)
- fileidx = filecnt - 1;
+ if (n < fileidx)
+ fileidx--;
if (n < alternate)
alternate--;
}
@@ -290,6 +290,7 @@ end:
void load_image(int new)
{
+ bool prev = new < fileidx;
static int current;
if (new < 0 || new >= filecnt)
@@ -307,7 +308,7 @@ void load_image(int new)
remove_file(new, false);
if (new >= filecnt)
new = filecnt - 1;
- else if (new > 0 && new < fileidx)
+ else if (new > 0 && prev)
new--;
}
files[new].flags &= ~FF_WARN;