mirror of https://github.com/bjornbytes/lovr.git
Handle coroutine stuff properly;
This commit is contained in:
parent
ce029cb5c5
commit
b28face914
|
@ -406,8 +406,8 @@ void bridgeLovrUpdate(BridgeLovrUpdateData *updateData) {
|
|||
coroutineStartFunctionRef = LUA_NOREF; // No longer needed
|
||||
}
|
||||
|
||||
luax_geterror(L);
|
||||
luax_clearerror(L);
|
||||
luax_geterror(Lcoroutine);
|
||||
luax_clearerror(Lcoroutine);
|
||||
if (lua_resume(Lcoroutine, 1) != LUA_YIELD) {
|
||||
if (lua_type(Lcoroutine, -1) == LUA_TSTRING && !strcmp(lua_tostring(Lcoroutine, -1), "restart")) {
|
||||
lua_close(L);
|
||||
|
|
12
src/main.c
12
src/main.c
|
@ -34,13 +34,13 @@ void lovrDestroy(void* arg) {
|
|||
|
||||
static void emscriptenLoop(void* arg) {
|
||||
lovrEmscriptenContext* context = arg;
|
||||
lua_State* L = context->L;
|
||||
luax_geterror(L);
|
||||
luax_clearerror(L);
|
||||
lua_State* T = context->T;
|
||||
|
||||
if (lua_resume(context->T, 1) != LUA_YIELD) {
|
||||
bool restart = lua_type(context->T, -1) == LUA_TSTRING && !strcmp(lua_tostring(context->T, -1), "restart");
|
||||
int status = lua_tonumber(context->T, -1);
|
||||
luax_geterror(T);
|
||||
luax_clearerror(T);
|
||||
if (lua_resume(T, 1) != LUA_YIELD) {
|
||||
bool restart = lua_type(T, -1) == LUA_TSTRING && !strcmp(lua_tostring(T, -1), "restart");
|
||||
int status = lua_tonumber(T, -1);
|
||||
|
||||
lua_close(context->L);
|
||||
emscripten_cancel_main_loop();
|
||||
|
|
Loading…
Reference in New Issue