Fix race condition on shutdown that could result in the program not completely exiting on Windows

Originally committed to SVN as r6729.
This commit is contained in:
Thomas Goyne 2012-05-01 02:49:26 +00:00
parent 81d1073a97
commit 2deafdd3a7

View file

@ -131,13 +131,16 @@ std::tr1::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum
} }
void *ThreadedFrameSource::Entry() { void *ThreadedFrameSource::Entry() {
while (!TestDestroy() && run) { while (!TestDestroy()) {
double time; double time;
int frameNum; int frameNum;
std::auto_ptr<AssFile> newSubs; std::auto_ptr<AssFile> newSubs;
{ {
wxMutexLocker jobLocker(jobMutex); wxMutexLocker jobLocker(jobMutex);
if (!run)
return EXIT_SUCCESS;
if (nextTime == -1.) { if (nextTime == -1.) {
jobReady.Wait(); jobReady.Wait();
continue; continue;
@ -191,9 +194,13 @@ ThreadedFrameSource::ThreadedFrameSource(wxString videoFileName, wxEvtHandler *p
Create(); Create();
Run(); Run();
} }
ThreadedFrameSource::~ThreadedFrameSource() { ThreadedFrameSource::~ThreadedFrameSource() {
run = false; {
jobReady.Signal(); wxMutexLocker locker(jobMutex);
run = false;
jobReady.Signal();
}
Wait(); Wait();
} }