SDL_image: showimage: Restore automation-friendly behaviour of -quit

From cec4127f77a81ad62a551c46b825d59098a8475c Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Tue, 17 May 2022 21:21:12 +0100
Subject: [PATCH] showimage: Restore automation-friendly behaviour of -quit

I added the -quit option for simple automated testing (with hindsight,
perhaps "-quit-after-loading" would have been a better name). The
intention was that something like

    showimage -quit -save out.bmp in.jpg -save out2.bmp in.png

would go through the motions of loading each image, save it to the
corresponding output file, but not actually wait for input or rendering.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 showimage.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/showimage.c b/showimage.c
index a9f1bf4..cf761fb 100644
--- a/showimage.c
+++ b/showimage.c
@@ -56,6 +56,7 @@ int main(int argc, char *argv[])
     Uint32 flags;
     int i, w, h;
     int done = 0;
+    int quit = 0;
     SDL_Event event;
     const char *saveFile = NULL;
 
@@ -89,7 +90,8 @@ int main(int argc, char *argv[])
         }
 
         if ( SDL_strcmp(argv[i], "-quit") == 0 ) {
-            break;
+            quit = 1;
+            continue;
         }
 
         if ( SDL_strcmp(argv[i], "-save") == 0 && argv[i+1] ) {
@@ -132,7 +134,7 @@ int main(int argc, char *argv[])
         SDL_SetWindowSize(window, w, h);
         SDL_ShowWindow(window);
 
-        done = 0;
+        done = quit;
         while ( !done ) {
             while ( SDL_PollEvent(&event) ) {
                 switch (event.type) {