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() ) 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 ) ) for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
{ {
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item ); SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
@ -628,9 +630,7 @@ int ERC_TESTER::TestLibSymbolIssues()
symbol->GetLibId().GetUniStringLibId() ); symbol->GetLibId().GetUniStringLibId() );
ercItem->SetErrorMessage( msg ); ercItem->SetErrorMessage( msg );
SCH_MARKER* marker = new SCH_MARKER( ercItem, symbol->GetPosition() ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
screen->Append( marker );
err_count += 1;
} }
else if( *libSymbol != *libSymbolInSchematic ) else if( *libSymbol != *libSymbolInSchematic )
{ {
@ -640,12 +640,16 @@ int ERC_TESTER::TestLibSymbolIssues()
symbol->GetLibId().GetUniStringLibId() ); symbol->GetLibId().GetUniStringLibId() );
ercItem->SetErrorMessage( msg ); ercItem->SetErrorMessage( msg );
SCH_MARKER* marker = new SCH_MARKER( ercItem, symbol->GetPosition() ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
}
}
for( SCH_MARKER* marker : markers )
{
screen->Append( marker ); screen->Append( marker );
err_count += 1; err_count += 1;
} }
} }
}
return err_count; return err_count;
} }