From f518bdadbdeec7043370d722a899c726ac5c2c64 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 9 Jan 2024 21:46:54 +0100 Subject: [PATCH] fix: Properly clear thread-local thread name --- lib/libimhex/source/api/task_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libimhex/source/api/task_manager.cpp b/lib/libimhex/source/api/task_manager.cpp index 183e3d7b6..a5b1f236a 100644 --- a/lib/libimhex/source/api/task_manager.cpp +++ b/lib/libimhex/source/api/task_manager.cpp @@ -29,6 +29,8 @@ namespace hex { std::condition_variable s_jobCondVar; std::vector s_workers; + thread_local std::string s_currentThreadName; + } @@ -56,6 +58,7 @@ namespace hex { Task::~Task() { if (!this->isFinished()) this->interrupt(); + s_currentThreadName.clear(); } void Task::update(u64 value) { @@ -277,6 +280,8 @@ namespace hex { s_deferredCalls.clear(); s_tasksFinishedCallbacks.clear(); + + s_currentThreadName.clear(); } TaskHolder TaskManager::createTask(std::string name, u64 maxValue, bool background, std::function function) { @@ -365,7 +370,6 @@ namespace hex { s_tasksFinishedCallbacks.push_back(function); } - thread_local static std::string s_currentThreadName; void TaskManager::setCurrentThreadName(const std::string &name) { s_currentThreadName = name; #if defined(OS_WINDOWS)