aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-11-06 10:55:47 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-11-06 10:55:47 +0000
commit0ceb3c4fc1bd4999fcde1aaeb81f7e9bf847d032 (patch)
tree46735aa5f008bfc44274b178b954ec2865da5ef9 /main.c
parenta7bc52c529f50f21f56485dd942889d947676156 (diff)
downloadimv-0ceb3c4fc1bd4999fcde1aaeb81f7e9bf847d032.tar.gz
Discard invalid paths
Diffstat (limited to 'main.c')
-rw-r--r--main.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/main.c b/main.c
index e6da41a..2c8a09e 100644
--- a/main.c
+++ b/main.c
@@ -63,7 +63,20 @@ void add_path(const char* path)
new_path->next = g_path.first;
g_path.last= new_path;
}
+}
+void remove_current_path()
+{
+ if(g_path.cur->next == g_path.cur) {
+ fprintf(stderr, "All input paths removed. Exiting\n");
+ exit(0);
+ }
+
+ struct loop_item_s* cur = g_path.cur;
+ cur->next->prev = cur->prev;
+ cur->prev->next = cur->next;
+ g_path.cur = cur->next;
+ free(cur);
}
void next_path()
@@ -172,13 +185,18 @@ int main(int argc, char** argv)
if(g_path.reload) {
if(img) {
SDL_DestroyTexture(img);
+ img = NULL;
}
img = imv_load_image(renderer, g_path.cur->path);
- g_path.reload = 0;
- reset_view();
+ if(img == NULL) {
+ remove_current_path();
+ } else {
+ g_path.reload = 0;
+ reset_view();
+ }
}
- if(g_view.redraw) {
+ if(g_view.redraw && img) {
SDL_RenderClear(renderer);
if(img) {