Handle coroutine stuff properly;

This commit is contained in:
bjorn 2019-03-07 01:04:45 -08:00
parent ce029cb5c5
commit b28face914
2 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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();