diff --git a/src/SFML/System/Unix/Thread.cpp b/src/SFML/System/Unix/Thread.cpp index 3268f610e..da02399ac 100644 --- a/src/SFML/System/Unix/Thread.cpp +++ b/src/SFML/System/Unix/Thread.cpp @@ -61,8 +61,7 @@ myUserData(UserData) Thread::~Thread() { // Wait for the thread to finish before destroying the instance - if (myIsActive) - Wait(); + Wait(); } @@ -71,6 +70,9 @@ Thread::~Thread() //////////////////////////////////////////////////////////// void Thread::Launch() { + // Wait for the thread to finish, in case it was already running + Wait(); + // Create the thread myIsActive = true; int Error = pthread_create(&myThread, NULL, &Thread::ThreadFunc, this); diff --git a/src/SFML/System/Win32/Thread.cpp b/src/SFML/System/Win32/Thread.cpp index d2d1d8226..3252100fa 100644 --- a/src/SFML/System/Win32/Thread.cpp +++ b/src/SFML/System/Win32/Thread.cpp @@ -62,8 +62,7 @@ myUserData(UserData) Thread::~Thread() { // Wait for the thread to finish before destroying the instance - if (myHandle) - Wait(); + Wait(); } @@ -72,6 +71,9 @@ Thread::~Thread() //////////////////////////////////////////////////////////// void Thread::Launch() { + // Wait for the thread to finish, in case it was already running + Wait(); + // Create the thread myHandle = reinterpret_cast(_beginthreadex(NULL, 0, &Thread::ThreadFunc, this, 0, NULL));