mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix segfault in deprecation logging due to tail call, log by default (#10174)
This commit is contained in:
parent
2dff3dd03f
commit
89dd05fdf3
9 changed files with 71 additions and 80 deletions
|
@ -155,24 +155,28 @@ static void script_log(lua_State *L, const std::string &message,
|
|||
infostream << script_get_backtrace(L) << std::endl;
|
||||
}
|
||||
|
||||
void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
|
||||
DeprecatedHandlingMode get_deprecated_handling_mode()
|
||||
{
|
||||
static thread_local bool configured = false;
|
||||
static thread_local bool do_log = false;
|
||||
static thread_local bool do_error = false;
|
||||
static thread_local DeprecatedHandlingMode ret = DeprecatedHandlingMode::Ignore;
|
||||
|
||||
// Only read settings on first call
|
||||
if (!configured) {
|
||||
std::string value = g_settings->get("deprecated_lua_api_handling");
|
||||
if (value == "log") {
|
||||
do_log = true;
|
||||
ret = DeprecatedHandlingMode::Log;
|
||||
} else if (value == "error") {
|
||||
do_log = true;
|
||||
do_error = true;
|
||||
ret = DeprecatedHandlingMode::Error;
|
||||
}
|
||||
configured = true;
|
||||
}
|
||||
|
||||
if (do_log)
|
||||
script_log(L, message, warningstream, do_error, stack_depth);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
|
||||
{
|
||||
DeprecatedHandlingMode mode = get_deprecated_handling_mode();
|
||||
if (mode != DeprecatedHandlingMode::Ignore)
|
||||
script_log(L, message, warningstream, mode == DeprecatedHandlingMode::Error, stack_depth);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue