Fixed compilation on Windows and avoid crashing when the TestSuite is interrupted.

This commit is contained in:
Xawotihs
2011-11-06 19:58:23 +00:00
parent e50fdba648
commit 1ef9489ea0
3 changed files with 26 additions and 18 deletions

View File

@@ -447,11 +447,23 @@ void TestSuite::handleResults(bool wasAI, int error)
}
}
TestSuite::~TestSuite()
{
mProcessing = false;
while(mWorkerThread.size())
{
mWorkerThread.back().join();
mWorkerThread.pop_back();
}
observer = 0;
}
TestSuite::TestSuite(const char * filename)
: TestSuiteGame(this), mRules(0), mProcessing(false)
: TestSuiteGame(0), mRules(0), mProcessing(false)
{
timerLimit = 0;
testsuite = this;
std::string s;
nbfiles = 0;
@@ -731,25 +743,20 @@ void TestSuite::ThreadProc(void* inParam)
{
string filename;
float counter = 1.0f;
// while(instance->mProcessing)
while(instance->mProcessing && (filename = instance->getNextFile()) != "")
{
while((filename = instance->getNextFile()) != "")
TestSuiteGame theGame(instance, filename);
if(theGame.isOK)
{
TestSuiteGame theGame(instance, filename);
if(theGame.isOK)
{
theGame.observer->loadTestSuitePlayer(0, &theGame);
theGame.observer->loadTestSuitePlayer(1, &theGame);
theGame.observer->loadTestSuitePlayer(0, &theGame);
theGame.observer->loadTestSuitePlayer(1, &theGame);
theGame.observer->startGame(theGame.gameType, instance->mRules);
theGame.initGame();
theGame.observer->startGame(theGame.gameType, instance->mRules);
theGame.initGame();
while(!theGame.observer->gameOver)
theGame.observer->Update(counter++);
}
while(!theGame.observer->gameOver)
theGame.observer->Update(counter++);
}
boost::this_thread::sleep(100);
}
}
LOG("Leaving TestSuite::ThreadProc");