fix: broken slideshow if redraw takes too long (#282)

currently the way check_timeout() is implemented, animate has higher
priority than slideshow. so if doing a redraw takes longer than the
frame delay of the animated image then it's going to continuously keep
animating and never reliably get to slideshow.

this issue can occur if the animated image has too fast of a delay or if
nsxiv is being run on a slow system where doing redraw takes too long.
the issue can be emulated by artificially slowing down img_render by
sticking a sleep in there.

	diff --git a/main.c b/main.c
	index 5dc52d4..0580011 100644
	--- a/main.c
	+++ b/main.c
	@@ -441,6 +441,7 @@ void redraw(void)

	 	if (mode == MODE_IMAGE) {
	 		img_render(&img);
	+		nanosleep(&(struct timespec){0, 62000000}, NULL); /* 62ms */
	 		if (img.ss.on) {
	 			t = img.ss.delay * 100;
	 			if (img.multi.cnt > 0 && img.multi.animate)

make it so that slideshow has higher priority than animate to fix
the issue.

Closes: https://github.com/nsxiv/nsxiv/issues/281
This commit is contained in:
N-R-K 2022-05-28 06:48:44 +00:00 committed by GitHub
parent b4268fbf38
commit 450797c573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

2
main.c
View File

@ -88,8 +88,8 @@ static struct {
static timeout_t timeouts[] = {
{ { 0, 0 }, false, redraw },
{ { 0, 0 }, false, reset_cursor },
{ { 0, 0 }, false, animate },
{ { 0, 0 }, false, slideshow },
{ { 0, 0 }, false, animate },
{ { 0, 0 }, false, clear_resize },
};