Don't invalidate itterator by adding markers inside loop.

Fixes https://gitlab.com/kicad/code/kicad/issues/6002
This commit is contained in:
Jeff Young 2020-10-19 15:32:30 +01:00
parent 725082786e
commit 3100273db1
1 changed files with 10 additions and 6 deletions

View File

@ -606,6 +606,8 @@ int ERC_TESTER::TestLibSymbolIssues()
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
{
std::vector<SCH_MARKER*> markers;
for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
{
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
@ -628,9 +630,7 @@ int ERC_TESTER::TestLibSymbolIssues()
symbol->GetLibId().GetUniStringLibId() );
ercItem->SetErrorMessage( msg );
SCH_MARKER* marker = new SCH_MARKER( ercItem, symbol->GetPosition() );
screen->Append( marker );
err_count += 1;
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
}
else if( *libSymbol != *libSymbolInSchematic )
{
@ -640,11 +640,15 @@ int ERC_TESTER::TestLibSymbolIssues()
symbol->GetLibId().GetUniStringLibId() );
ercItem->SetErrorMessage( msg );
SCH_MARKER* marker = new SCH_MARKER( ercItem, symbol->GetPosition() );
screen->Append( marker );
err_count += 1;
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
}
}
for( SCH_MARKER* marker : markers )
{
screen->Append( marker );
err_count += 1;
}
}
return err_count;