From 73a7dd2818c8eb2d46b2065347030691bfc8140a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 May 2012 15:24:13 +0000 Subject: Fix Thread::get() when called before any Thread is created. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4378 a436a847-0d15-0410-975c-d299462d15a1 --- src/Thread.cpp | 1 + test/thread_test.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Thread.cpp b/src/Thread.cpp index e35d347..a2d79c3 100644 --- a/src/Thread.cpp +++ b/src/Thread.cpp @@ -79,6 +79,7 @@ Thread::create_for_this_thread(const std::string& name) Thread& Thread::get() { + pthread_once(&s_thread_key_once, thread_key_alloc); Thread* this_thread = reinterpret_cast( pthread_getspecific(s_thread_key)); if (!this_thread) diff --git a/test/thread_test.cpp b/test/thread_test.cpp index 03dbaa9..176e544 100644 --- a/test/thread_test.cpp +++ b/test/thread_test.cpp @@ -24,8 +24,6 @@ private: int main() { - Thread::create_for_this_thread(); - Thread& this_thread = Thread::get(); this_thread.set_name("Main"); -- cgit v1.2.1