mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01:49 +00:00
fix segfaults due to access to dead lua states (coroutines)
This commit is contained in:
parent
39fcc10dd8
commit
41dfcad474
1 changed files with 3 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue