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
1 changed files with 10 additions and 3 deletions

View File

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