Skip to content

Commit 4361bfc

Browse files
authoredApr 21, 2020
Fix configuration caching in log_deprecated (#9697)
* Fix configuration caching in log_deprecated The configured variable was never set to true. I've set the variables to thread_local because the configuration should be reloaded after reentering the world from mainmenu.
1 parent 8ef239b commit 4361bfc

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed
 

Diff for: ‎src/script/common/c_internal.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,20 @@ static void script_log(lua_State *L, const std::string &message,
157157

158158
void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
159159
{
160-
static bool configured = false;
161-
static bool do_log = false;
162-
static bool do_error = false;
160+
static thread_local bool configured = false;
161+
static thread_local bool do_log = false;
162+
static thread_local bool do_error = false;
163163

164164
// Only read settings on first call
165165
if (!configured) {
166166
std::string value = g_settings->get("deprecated_lua_api_handling");
167167
if (value == "log") {
168168
do_log = true;
169169
} else if (value == "error") {
170-
do_log = true;
170+
do_log = true;
171171
do_error = true;
172172
}
173+
configured = true;
173174
}
174175

175176
if (do_log)

Diff for: ‎src/script/lua_api/l_util.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4444

4545
// log([level,] text)
4646
// Writes a line to the logger.
47-
// The one-argument version logs to infostream.
47+
// The one-argument version logs to LL_NONE.
4848
// The two-argument version accepts a log level.
4949
// Either the special case "deprecated" for deprecation notices, or any specified in
5050
// Logger::stringToLevel(name).

Diff for: ‎src/script/lua_api/l_util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ModApiUtil : public ModApiBase
3737

3838
// log([level,] text)
3939
// Writes a line to the logger.
40-
// The one-argument version logs to infostream.
40+
// The one-argument version logs to LL_NONE.
4141
// The two-argument version accepts a log level.
4242
static int l_log(lua_State *L);
4343

0 commit comments

Comments
 (0)
Please sign in to comment.