From 2c4ad51d44c15c45135cd5b6ff32b2a7e1f24bf7 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 18 May 2015 21:21:14 +0200 Subject: [PATCH] Added missing loop cancel for Emscripten in test programs. --- test/checkkeys.c | 5 +++++ test/testdraw2.c | 5 +++++ test/testdrawchessboard.c | 6 ++++++ test/testgamecontroller.c | 6 ++++++ test/testgesture.c | 6 ++++++ test/testgles2.c | 5 +++++ test/testintersections.c | 5 +++++ test/testjoystick.c | 6 ++++++ test/testoverlay2.c | 6 ++++++ test/testrelative.c | 5 +++++ test/testrendercopyex.c | 5 +++++ test/testrendertarget.c | 5 +++++ test/testscale.c | 5 +++++ test/testsprite2.c | 5 +++++ test/testspriteminimal.c | 5 +++++ test/teststreaming.c | 6 ++++++ test/testviewport.c | 6 ++++++ test/testwm2.c | 5 +++++ 18 files changed, 97 insertions(+) diff --git a/test/checkkeys.c b/test/checkkeys.c index 234b627b6..059192836 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 7685e3b2e..b0f706a3e 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 35cc6884b..ef89c2de7 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 414872cf2..2eb3686b4 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 6189f4504..8982e15d9 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 55f06cb43..af02c1f1a 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 77bb51460..f47053815 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 adb376e02..b35a5e120 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 69238fa42..4a8b51b8b 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 3b6ef810e..68ec24cb1 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 379819ce2..0cfa9ba20 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 c03e6394b..0471ec248 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 e52eacb43..124138e41 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 17a9cd5f4..d02acda71 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 fc7d31f17..82bee9c19 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 da618c4cf..9b2888b11 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 2ac8031ab..385bbbd12 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 8d8ff4613..02a0ce2df 100644 --- a/test/testwm2.c +++ b/test/testwm2.c @@ -100,6 +100,11 @@ loop() } } } +#ifdef __EMSCRIPTEN__ + if (done) { + emscripten_cancel_main_loop(); + } +#endif } int