From dd3ccc7b80d3430565fbc7014d5ba4a92afbd1d4 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Wed, 15 Dec 2021 11:12:08 +0000
Subject: [PATCH] showanim: Add a command-line option to loop once and then
exit
Similar to showimage -quit, this allows it to be used as a
non-interactive smoke-test.
Signed-off-by: Simon McVittie <smcv@debian.org>
---
showanim.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/showanim.c b/showanim.c
index 21670d3..ba4959a 100644
--- a/showanim.c
+++ b/showanim.c
@@ -56,6 +56,7 @@ int main(int argc, char *argv[])
SDL_Texture **textures;
Uint32 flags;
int i, j, w, h, done;
+ int once = 0;
int current_frame, delay;
SDL_Event event;
@@ -88,6 +89,11 @@ int main(int argc, char *argv[])
continue;
}
+ if ( SDL_strcmp(argv[i], "-once") == 0 ) {
+ once = 1;
+ continue;
+ }
+
/* Open the image file */
anim = IMG_LoadAnimation(argv[i]);
if (!anim) {
@@ -168,6 +174,10 @@ int main(int argc, char *argv[])
SDL_Delay(delay);
current_frame = (current_frame + 1) % anim->count;
+
+ if (once && current_frame == 0) {
+ break;
+ }
}
for (j = 0; j < anim->count; ++j) {