Use PdmPointers for command queue in RiaApplication

This commit is contained in:
Gaute Lindkvist 2020-10-23 10:57:57 +02:00
parent 49ffe9b53a
commit e847ce7cd3
2 changed files with 13 additions and 19 deletions

View File

@ -1302,31 +1302,25 @@ void RiaApplication::addCommandObject( RimCommandObject* commandObject )
void RiaApplication::executeCommandObjects()
{
{
std::list<RimCommandObject*>::iterator it = m_commandQueue.begin();
while ( it != m_commandQueue.end() )
auto currentCommandQueue = m_commandQueue;
for ( auto command : currentCommandQueue )
{
RimCommandObject* toBeRemoved = *it;
if ( !toBeRemoved->isAsyncronous() )
if ( command->isAsyncronous() )
{
toBeRemoved->redo();
++it;
m_commandQueue.remove( toBeRemoved );
}
else
{
++it;
command->redo();
m_commandQueue.remove( command );
}
}
}
if ( !m_commandQueue.empty() )
{
std::list<RimCommandObject*>::iterator it = m_commandQueue.begin();
RimCommandObject* first = *it;
first->redo();
auto it = m_commandQueue.begin();
if ( it->notNull() )
{
RimCommandObject* first = *it;
first->redo();
}
m_commandQueue.pop_front();
}
else

View File

@ -262,8 +262,8 @@ protected:
QString m_commandLineHelpText;
QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session
std::list<RimCommandObject*> m_commandQueue;
QMutex m_commandQueueLock;
std::list<caf::PdmPointer<RimCommandObject>> m_commandQueue;
QMutex m_commandQueueLock;
bool m_runningWorkerProcess;