From 38ea296f44bb61bc64bf74bc45b2a23284a4a8b0 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Thu, 4 May 2017 20:59:42 +0900 Subject: [PATCH] Stop mainloop on exit --- src/nact.h | 1 + src/xsystem35.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/nact.h b/src/nact.h index 4a67cba..37422f3 100644 --- a/src/nact.h +++ b/src/nact.h @@ -144,6 +144,7 @@ typedef struct { #ifdef ENABLE_SDL enum { InputNotChecked, InputCheckMissed, HadInput } input_state; +#define BREAK_MAINLOOP (nact->input_state = InputCheckMissed) #endif } NACTINFO; diff --git a/src/xsystem35.c b/src/xsystem35.c index 9247685..689e932 100644 --- a/src/xsystem35.c +++ b/src/xsystem35.c @@ -44,6 +44,9 @@ extern char *mkdtemp (char *template); #endif +#ifdef __EMSCRIPTEN__ +#include +#endif #include "nact.h" #include "portab.h" @@ -221,7 +224,13 @@ void sys_error(char *format, ...) { void sys_exit(int code) { sys35_remove(); +#ifdef EMSCRIPTEN + emscripten_cancel_main_loop(); + EM_ASM( xsystem35.shell.quit(); ); + BREAK_MAINLOOP; +#else exit(code); +#endif } static int check_fontdev(char *devname) {