fix segfaults due to access to dead lua states (coroutines)
This commit is contained in:
parent
39fcc10dd8
commit
41dfcad474
@ -1,4 +1,5 @@
|
|||||||
#include "lua_util.hpp"
|
#include "lua_util.hpp"
|
||||||
|
#include "lua_engine.hpp"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -228,6 +229,7 @@ static std::shared_ptr<std::string> create_lambda_handler(State* L) {
|
|||||||
return std::shared_ptr<std::string>(
|
return std::shared_ptr<std::string>(
|
||||||
new std::string(name),
|
new std::string(name),
|
||||||
[=](std::string* name) {
|
[=](std::string* name) {
|
||||||
|
auto L = lua::get_main_state();
|
||||||
requireglobal(L, LAMBDAS_TABLE);
|
requireglobal(L, LAMBDAS_TABLE);
|
||||||
pushnil(L);
|
pushnil(L);
|
||||||
setfield(L, *name);
|
setfield(L, *name);
|
||||||
@ -240,6 +242,7 @@ static std::shared_ptr<std::string> create_lambda_handler(State* L) {
|
|||||||
runnable lua::create_runnable(State* L) {
|
runnable lua::create_runnable(State* L) {
|
||||||
auto funcptr = create_lambda_handler(L);
|
auto funcptr = create_lambda_handler(L);
|
||||||
return [=]() {
|
return [=]() {
|
||||||
|
auto L = lua::get_main_state();
|
||||||
if (!get_from(L, LAMBDAS_TABLE, *funcptr, false))
|
if (!get_from(L, LAMBDAS_TABLE, *funcptr, false))
|
||||||
return;
|
return;
|
||||||
call_nothrow(L, 0, 0);
|
call_nothrow(L, 0, 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user