Make sure ERC has a current sheet to resolve text vars with.

Fixes https://gitlab.com/kicad/code/kicad/issues/5318
This commit is contained in:
Jeff Young 2020-08-23 22:41:52 +01:00
parent e343234c61
commit 605ddce651
1 changed files with 8 additions and 2 deletions

View File

@ -160,10 +160,14 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
wsItems.BuildWorkSheetGraphicList( aWorksheet->GetPageInfo(), aWorksheet->GetTitleBlock() ); wsItems.BuildWorkSheetGraphicList( aWorksheet->GetPageInfo(), aWorksheet->GetTitleBlock() );
} }
SCH_SCREENS screens( m_schematic->Root() ); SCH_SHEET_PATH savedCurrentSheet = m_schematic->CurrentSheet();
SCH_SHEET_LIST sheets = m_schematic->GetSheets();
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() ) for( SCH_SHEET_PATH& sheet : sheets )
{ {
m_schematic->SetCurrentSheet( sheet );
SCH_SCREEN* screen = sheet.LastScreen();
for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) ) for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
{ {
if( item->Type() == SCH_COMPONENT_T ) if( item->Type() == SCH_COMPONENT_T )
@ -242,6 +246,8 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
} }
} }
} }
m_schematic->SetCurrentSheet( savedCurrentSheet );
} }