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() void RiaApplication::executeCommandObjects()
{ {
{ {
std::list<RimCommandObject*>::iterator it = m_commandQueue.begin(); auto currentCommandQueue = m_commandQueue;
while ( it != m_commandQueue.end() ) for ( auto command : currentCommandQueue )
{ {
RimCommandObject* toBeRemoved = *it; if ( command->isAsyncronous() )
if ( !toBeRemoved->isAsyncronous() )
{ {
toBeRemoved->redo(); command->redo();
m_commandQueue.remove( command );
++it;
m_commandQueue.remove( toBeRemoved );
}
else
{
++it;
} }
} }
} }
if ( !m_commandQueue.empty() ) if ( !m_commandQueue.empty() )
{ {
std::list<RimCommandObject*>::iterator it = m_commandQueue.begin(); auto it = m_commandQueue.begin();
if ( it->notNull() )
RimCommandObject* first = *it; {
first->redo(); RimCommandObject* first = *it;
first->redo();
}
m_commandQueue.pop_front(); m_commandQueue.pop_front();
} }
else else

View File

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