Commit 2c4ad51d44c15c45135cd5b6ff32b2a7e1f24bf7

Philipp Wiesemann 2015-05-18T21:21:14

Added missing loop cancel for Emscripten in test programs.

diff --git a/test/checkkeys.c b/test/checkkeys.c
index 234b627..0591928 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -162,6 +162,11 @@ loop()
             break;
         }
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testdraw2.c b/test/testdraw2.c
index 7685e3b..b0f706a 100644
--- a/test/testdraw2.c
+++ b/test/testdraw2.c
@@ -198,6 +198,11 @@ loop()
 
         SDL_RenderPresent(renderer);
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c
index 35cc688..ef89c2d 100644
--- a/test/testdrawchessboard.c
+++ b/test/testdrawchessboard.c
@@ -62,11 +62,17 @@ loop()
     while (SDL_PollEvent(&e)) {
 		if (e.type == SDL_QUIT) {
 			done = 1;
+#ifdef __EMSCRIPTEN__
+			emscripten_cancel_main_loop();
+#endif
 			return;
 		}
 
 		if(e.key.keysym.sym == SDLK_ESCAPE) {
 			done = 1;
+#ifdef __EMSCRIPTEN__
+			emscripten_cancel_main_loop();
+#endif
 			return;
 		}
 	}
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 414872c..2eb3686 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -153,6 +153,12 @@ loop(void *arg)
         done = SDL_TRUE;
         retval = SDL_TRUE;  /* keep going, wait for reattach. */
     }
+
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 SDL_bool
diff --git a/test/testgesture.c b/test/testgesture.c
index 6189f45..8982e15 100644
--- a/test/testgesture.c
+++ b/test/testgesture.c
@@ -266,6 +266,12 @@ void loop()
       }
     }
     DrawScreen(screen, window);
+
+#ifdef __EMSCRIPTEN__
+    if (quitting) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int main(int argc, char* argv[])
diff --git a/test/testgles2.c b/test/testgles2.c
index 55f06cb..af02c1f 100644
--- a/test/testgles2.c
+++ b/test/testgles2.c
@@ -466,6 +466,11 @@ void loop()
           SDL_GL_SwapWindow(state->windows[i]);
       }
     }
+#ifdef __EMSCRIPTEN__
+    else {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testintersections.c b/test/testintersections.c
index 77bb514..f470538 100644
--- a/test/testintersections.c
+++ b/test/testintersections.c
@@ -257,6 +257,11 @@ loop()
 
         SDL_RenderPresent(renderer);
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testjoystick.c b/test/testjoystick.c
index adb376e..b35a5e1 100644
--- a/test/testjoystick.c
+++ b/test/testjoystick.c
@@ -175,6 +175,12 @@ loop(void *arg)
             done = SDL_TRUE;
             retval = SDL_TRUE;  /* keep going, wait for reattach. */
         }
+
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 static SDL_bool
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
index 69238fa..4a8b51b 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -312,6 +312,12 @@ loop()
     SDL_RenderClear(renderer);
     SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
     SDL_RenderPresent(renderer);
+
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testrelative.c b/test/testrelative.c
index 3b6ef81..68ec24c 100644
--- a/test/testrelative.c
+++ b/test/testrelative.c
@@ -67,6 +67,11 @@ loop(){
 
         SDL_RenderPresent(renderer);
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c
index 379819c..0cfa9ba 100644
--- a/test/testrendercopyex.c
+++ b/test/testrendercopyex.c
@@ -152,6 +152,11 @@ void loop()
             continue;
         Draw(&drawstates[i]);
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testrendertarget.c b/test/testrendertarget.c
index c03e639..0471ec2 100644
--- a/test/testrendertarget.c
+++ b/test/testrendertarget.c
@@ -241,6 +241,11 @@ loop()
             if (!Draw(&drawstates[i])) done = 1;
         }
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testscale.c b/test/testscale.c
index e52eacb..124138e 100644
--- a/test/testscale.c
+++ b/test/testscale.c
@@ -142,6 +142,11 @@ loop()
             continue;
         Draw(&drawstates[i]);
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testsprite2.c b/test/testsprite2.c
index 17a9cd5..d02acda 100644
--- a/test/testsprite2.c
+++ b/test/testsprite2.c
@@ -251,6 +251,11 @@ loop()
             continue;
         MoveSprites(state->renderers[i], sprites[i]);
     }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c
index fc7d31f..82bee9c 100644
--- a/test/testspriteminimal.c
+++ b/test/testspriteminimal.c
@@ -136,6 +136,11 @@ void loop()
         }
     }
     MoveSprites(renderer, sprite);
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/teststreaming.c b/test/teststreaming.c
index da618c4..9b2888b 100644
--- a/test/teststreaming.c
+++ b/test/teststreaming.c
@@ -115,6 +115,12 @@ loop()
     SDL_RenderClear(renderer);
     SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
     SDL_RenderPresent(renderer);
+
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testviewport.c b/test/testviewport.c
index 2ac8031..385bbbd 100644
--- a/test/testviewport.c
+++ b/test/testviewport.c
@@ -129,6 +129,12 @@ loop()
             SDL_RenderPresent(state->renderers[i]);
         }
     }
+
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int
diff --git a/test/testwm2.c b/test/testwm2.c
index 8d8ff46..02a0ce2 100644
--- a/test/testwm2.c
+++ b/test/testwm2.c
@@ -100,6 +100,11 @@ loop()
                 }
             }
         }
+#ifdef __EMSCRIPTEN__
+    if (done) {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
 
 int