Use a mutex to make sure all command objects have completed before issuing snapshots in the regression tests.

p4#: 22400
This commit is contained in:
Magne Sjaastad 2013-09-13 09:23:33 +02:00
parent 1543f05794
commit 74b6b858d3
2 changed files with 20 additions and 0 deletions

View File

@ -356,6 +356,10 @@ bool RiaApplication::loadProject(const QString& projectFileName)
m_commandQueue.push_back(m_project->commandObjects[i]);
}
// Lock the command queue
m_commandQueueLock.lock();
// Execute command objects, and release the mutex when the queue is empty
executeCommandObjects();
onProjectOpenedOrClosed();
@ -1374,6 +1378,14 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
if (testCaseFolder.exists(regTestProjectName))
{
loadProject(testCaseFolder.filePath(regTestProjectName));
// Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();
saveSnapshotForAllViews(generatedFolderName);
QDir baseDir(testCaseFolder.filePath(baseFolderName));
@ -1716,5 +1728,10 @@ void RiaApplication::executeCommandObjects()
m_commandQueue.pop_front();
}
else
{
// Unlock the command queue lock when the command queue is empty
m_commandQueueLock.unlock();
}
}

View File

@ -19,6 +19,8 @@
#pragma once
#include <QApplication>
#include <QProcess>
#include <QMutex>
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cvfBase.h"
@ -174,4 +176,5 @@ private:
QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session
std::list<RimCommandObject*> m_commandQueue;
QMutex m_commandQueueLock;
};