Merge pull request #5645 from stevecotton/wfl_error_thread_114

[1.14] Make WFL's error-reporting machinery thread_local
This commit is contained in:
Charles Dang 2021-04-01 10:19:41 -04:00 committed by GitHub
commit f64af2e6a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -4,6 +4,7 @@
### Translations
### User interface
### Miscellaneous and Bug Fixes
* Fixed an intermittent crash on the loading screen (issue #5629)
## Version 1.14.16
### AI

View file

@ -36,7 +36,13 @@ static lg::log_domain log_scripting_formula("scripting/formula");
namespace wfl
{
static std::deque<std::string> call_stack;
/**
* For printing error messages when WFL parsing or evaluation fails, this contains the names of the WFL functions being evaluated.
*
* Two C++ threads might be evaluating WFL at the same; declaring this thread_local is a quick bugfix which should probably be replaced
* by having a context-object for each WFL evaluation.
*/
thread_local static std::deque<std::string> call_stack;
call_stack_manager::call_stack_manager(const std::string& str)
{

View file

@ -47,9 +47,14 @@ namespace wfl
#define DECLARE_WFL_FUNCTION(name) \
functions_table.add_function(#name, std::make_shared<builtin_formula_function<name##_function>>(#name))
/**
* Provides debugging information for error messages.
*/
struct call_stack_manager
{
explicit call_stack_manager(const std::string& str);
call_stack_manager(const call_stack_manager&) = delete;
call_stack_manager& operator=(const call_stack_manager&) = delete;
~call_stack_manager();
static std::string get();