Fix a potential crash when a Thread ends (resolves issue #1219).

This commit is contained in:
Alex Szpakowski
2016-10-08 10:50:50 -03:00
parent 304ccec71c
commit b1b4a637b5
6 changed files with 16 additions and 12 deletions
+10 -3
View File
@@ -29,7 +29,7 @@ namespace sdl
Thread::Thread(Threadable *t)
: t(t)
, running(false)
, thread(0)
, thread(nullptr)
{
}
@@ -74,9 +74,16 @@ bool Thread::isRunning()
int Thread::thread_runner(void *data)
{
Thread *self = (Thread *) data; // some compilers don't like 'this'
self->t->retain();
self->t->threadFunction();
Lock l(self->mutex);
self->running = false;
{
Lock l(self->mutex);
self->running = false;
}
self->t->release();
return 0;
}
} // sdl