From f48bebb3c4ad6941941ec889ce8b1c5f15c9a1c1 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 24 Apr 2016 11:38:44 +0200 Subject: Fix slide changing with empty slide --- src/presentation.c | 34 +++++++--------------------------- src/slideshow.c | 2 +- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/presentation.c b/src/presentation.c index 266535c..816f854 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -244,31 +244,13 @@ int num_slides(struct presentation *p) } -/* Warning: isn't very clever and assumes the block we want is at the top - * level */ -static SCBlock *parent_block(struct presentation *p, SCBlock *findme) -{ - SCBlock *bl; - - bl = p->scblocks; - - while ( bl != NULL ) { - if ( sc_block_child(bl) == findme ) return bl; - bl = sc_block_next(bl); - } - - printf("Whoops, couldn't find parent!\n"); - return bl; -} - - SCBlock *first_slide(struct presentation *p) { SCBlock *bl = p->scblocks; while ( bl != NULL ) { if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { - return sc_block_child(bl); + return bl; } bl = sc_block_next(bl); } @@ -293,21 +275,20 @@ SCBlock *last_slide(struct presentation *p) if ( l == NULL ) { fprintf(stderr, "Couldn't find last slide!\n"); } - return sc_block_child(l); + return l; } SCBlock *next_slide(struct presentation *p, SCBlock *sl) { - SCBlock *pp = parent_block(p, sl); - SCBlock *bl = pp; + SCBlock *bl = sl; int found = 0; while ( bl != NULL ) { if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { - if ( found ) return sc_block_child(bl); + if ( found ) return bl; } - if ( bl == pp ) { + if ( bl == sl ) { found = 1; } bl = sc_block_next(bl); @@ -320,14 +301,13 @@ SCBlock *next_slide(struct presentation *p, SCBlock *sl) SCBlock *prev_slide(struct presentation *p, SCBlock *sl) { - SCBlock *pp = parent_block(p, sl); SCBlock *bl = p->scblocks; SCBlock *l = NULL; while ( bl != NULL ) { - if ( bl == pp ) { + if ( bl == sl ) { if ( l == NULL ) return sl; /* Already on first slide */ - return sc_block_child(l); + return l; } if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { l = bl; diff --git a/src/slideshow.c b/src/slideshow.c index 6a8faf9..b1287e1 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -82,7 +82,7 @@ void slideshow_rerender(SlideShow *ss) stylesheets[1] = NULL; n = slide_number(ss->p, ss->cur_slide); - ss->surface = render_sc(ss->cur_slide, + ss->surface = render_sc(sc_block_child(ss->cur_slide), ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, stylesheets, NULL, ss->p->is, ISZ_SLIDESHOW, n, -- cgit v1.2.3