From 8feb53e509672b9208abbd56936f6e80e65b3a6e Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 9 Mar 2021 08:40:30 +0200 Subject: [PATCH] Move caller_id init to Thread constructor to fix UWP build. (cherry picked from commit 741e1cf6725e699f3dba7b4794f55bcbdba5dcb0) --- core/os/thread.cpp | 6 +++++- core/os/thread.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/os/thread.cpp b/core/os/thread.cpp index ca1752ffb03..1f260c08e34 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -47,7 +47,7 @@ uint64_t Thread::_thread_id_hash(const std::thread::id &p_t) { } Thread::ID Thread::main_thread_id = _thread_id_hash(std::this_thread::get_id()); -thread_local Thread::ID Thread::caller_id = _thread_id_hash(std::this_thread::get_id()); +thread_local Thread::ID Thread::caller_id = 0; void Thread::_set_platform_funcs( Error (*p_set_name_func)(const String &), @@ -112,6 +112,10 @@ Error Thread::set_name(const String &p_name) { return ERR_UNAVAILABLE; } +Thread::Thread() { + caller_id = _thread_id_hash(std::this_thread::get_id()); +} + Thread::~Thread() { if (id != _thread_id_hash(std::thread::id())) { #ifdef DEBUG_ENABLED diff --git a/core/os/thread.h b/core/os/thread.h index 3c617648259..527c86c0221 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -98,6 +98,7 @@ public: ///< waits until thread is finished, and deallocates it. void wait_to_finish(); + Thread(); ~Thread(); #else _FORCE_INLINE_ ID get_id() const { return 0; }