Fixed possible leak in sf::Thread implementation (thread handles could be lost if the same sf::Thread was launched again before finishing)
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1441 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
dec1820537
commit
b3ca862273
@ -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);
|
||||
|
@ -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<HANDLE>(_beginthreadex(NULL, 0, &Thread::ThreadFunc, this, 0, NULL));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user