From 1000893652adc5177a84281bd6653ab311022c76 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 28 Jul 2020 18:35:42 +0200 Subject: [PATCH] Make C Interface exceptions thread local. --- CInterface/Core.cpp | 1 - CInterface/Core.hpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CInterface/Core.cpp b/CInterface/Core.cpp index f38b4a6..f2682cf 100644 --- a/CInterface/Core.cpp +++ b/CInterface/Core.cpp @@ -1,4 +1,3 @@ #include "Core.hpp" -std::string ExceptionHandler::_lastException = ""; export const char* Arbutils_C_GetLastException() { return ExceptionHandler::GetLastException(); } diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index c01e58c..4e27496 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -9,11 +9,11 @@ #define ArbutilsException 3; class ExceptionHandler { - static std::string _lastException; + static thread_local std::string _ArbutilsLastException; public: - static void SetLastException(const std::exception& e) { _lastException = std::string(e.what()); } - static const char* GetLastException() { return _lastException.c_str(); } + static void SetLastException(const std::exception& e) { _ArbutilsLastException = std::string(e.what()); } + static const char* GetLastException() { return _ArbutilsLastException.c_str(); } }; #define Try(data) \