Check envvars as well before flagging as un-resolved.

Fixes https://gitlab.com/kicad/code/kicad/issues/4644
This commit is contained in:
Jeff Young 2020-07-31 23:56:42 +01:00
parent 9977299340
commit e86fc64e7d
2 changed files with 9 additions and 3 deletions

View File

@ -482,7 +482,7 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject )
size_t m = n + 1; size_t m = n + 1;
wxUniChar str_m = str[m]; wxUniChar str_m = str[m];
while( m < strlen && ( wxIsalnum( str_m ) || str_m == wxT( '_' ) ) ) while( m < strlen && ( wxIsalnum( str_m ) || str_m == wxT( '_' ) || str_m == wxT( ':' ) ) )
str_m = str[++m]; str_m = str[++m];
wxString strVarName( str.c_str() + n + 1, m - n - 1 ); wxString strVarName( str.c_str() + n + 1, m - n - 1 );

View File

@ -148,6 +148,12 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{ {
WS_DRAW_ITEM_LIST wsItems; WS_DRAW_ITEM_LIST wsItems;
auto unresolved = [this]( wxString str )
{
str = ExpandEnvVarSubstitutions( str, &m_schematic->Prj() );
return str.Matches( wxT( "*${*}*" ) );
};
if( aWorksheet ) if( aWorksheet )
{ {
wsItems.SetMilsToIUfactor( IU_PER_MILS ); wsItems.SetMilsToIUfactor( IU_PER_MILS );
@ -166,7 +172,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
for( SCH_FIELD& field : component->GetFields() ) for( SCH_FIELD& field : component->GetFields() )
{ {
if( field.GetShownText().Matches( wxT( "*${*}*" ) ) ) if( unresolved( field.GetShownText() ) )
{ {
wxPoint pos = field.GetPosition() - component->GetPosition(); wxPoint pos = field.GetPosition() - component->GetPosition();
pos = component->GetTransform().TransformCoordinate( pos ); pos = component->GetTransform().TransformCoordinate( pos );
@ -186,7 +192,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
for( SCH_FIELD& field : sheet->GetFields() ) for( SCH_FIELD& field : sheet->GetFields() )
{ {
if( field.GetShownText().Matches( wxT( "*${*}*" ) ) ) if( unresolved( field.GetShownText() ) )
{ {
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
ercItem->SetItems( &field ); ercItem->SetItems( &field );