Skip to content

Commit 9181bde

Browse files
committed
added force_exit for emscripten
1 parent 087a891 commit 9181bde

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cmake/sokol.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ if(BUILD_SOKOL)
9696
elseif(EMSCRIPTEN)
9797
add_executable(tic80 ${TIC80_SRC})
9898

99-
set(LINK_FLAGS "-s EXPORT_ES6=1 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['$dynCall','$writeArrayToMemory'] -s EXPORTED_RUNTIME_METHODS=['FS'] -s EXPORTED_FUNCTIONS=['_main','_free']")
99+
set(LINK_FLAGS "-s EXPORT_ES6=1 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['$dynCall','$writeArrayToMemory'] -s EXPORTED_RUNTIME_METHODS=['FS'] -s EXPORTED_FUNCTIONS=['_main','_free','_force_exit']")
100100

101101
if(BUILD_SOKOL_WEBGPU)
102102
set_target_properties(tic80 PROPERTIES LINK_FLAGS "${LINK_FLAGS} --use-port=emdawnwebgpu")

src/studio/studio.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2773,9 +2773,23 @@ void studio_keymapchanged(Studio* studio, tic_kbdlayout kbdlayout)
27732773
studio->config->data.options.kbdlayout = kbdlayout;
27742774
}
27752775

2776+
#if defined(__TIC_EMSCRIPTEN__)
2777+
static bool forceExitFlag = false;
2778+
2779+
void force_exit()
2780+
{
2781+
forceExitFlag = true;
2782+
}
2783+
2784+
#endif
2785+
27762786
bool studio_alive(Studio* studio)
27772787
{
2778-
return !studio->quit;
2788+
return !studio->quit
2789+
#if defined(__TIC_EMSCRIPTEN__)
2790+
&& !forceExitFlag
2791+
#endif
2792+
;
27792793
}
27802794

27812795
#if defined(TIC_MODULE_EXT)

0 commit comments

Comments
 (0)