Don't try to resolve variables before the schematic is set up.

Fixes https://gitlab.com/kicad/code/kicad/issues/8746
This commit is contained in:
Jeff Young 2021-07-07 21:52:55 +01:00
parent d6420d458e
commit d51ac65349
2 changed files with 26 additions and 21 deletions

View File

@ -695,7 +695,7 @@ int SCH_SHEET::CountSheets() const
if( m_screen )
{
for( auto aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
count += static_cast<SCH_SHEET*>( aItem )->CountSheets();
}

View File

@ -122,29 +122,34 @@ SCH_SCREEN* SCHEMATIC::RootScreen() const
bool SCHEMATIC::ResolveTextVar( wxString* token, int aDepth ) const
{
if( token->IsSameAs( wxT( "#" ) ) )
if( !CurrentSheet().empty() )
{
*token = CurrentSheet().GetPageNumber();
return true;
}
else if( token->IsSameAs( wxT( "##" ) ) )
{
*token = wxString::Format( "%i", Root().CountSheets() );
return true;
}
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
{
*token = CurrentSheet().PathHumanReadable();
return true;
}
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
{
wxFileName fn( GetFileName() );
*token = fn.GetFullName();
return true;
if( token->IsSameAs( wxT( "#" ) ) )
{
*token = CurrentSheet().GetPageNumber();
return true;
}
else if( token->IsSameAs( wxT( "##" ) ) )
{
*token = wxString::Format( "%i", Root().CountSheets() );
return true;
}
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
{
*token = CurrentSheet().PathHumanReadable();
return true;
}
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
{
wxFileName fn( GetFileName() );
*token = fn.GetFullName();
return true;
}
return CurrentSheet().LastScreen()->GetTitleBlock().TextVarResolver( token, m_project );
}
return CurrentSheet().LastScreen()->GetTitleBlock().TextVarResolver( token, m_project );
return false;
}