Improvements to ERC and bus parsing.

1) Add some nullptr safety to ERC.
2) Allow unconnected flagging on bus/wire entries.
3) Allow commas in bus group definitions.

Fixes https://gitlab.com/kicad/code/kicad/issues/7155
This commit is contained in:
Jeff Young 2021-01-17 16:05:09 +00:00
parent f1221a9ca3
commit f3a6d2655e
2 changed files with 18 additions and 6 deletions

View File

@ -459,17 +459,18 @@ bool NET_SETTINGS::ParseBusGroup( wxString aGroup, wxString* aName,
}
else
{
if( aMemberList )
if( aMemberList && !tmp.IsEmpty() )
aMemberList->push_back( EscapeString( tmp, CTX_NETNAME ) );
return true;
}
}
if( aGroup[i] == ' ' )
// Commas aren't strictly legal, but we can be pretty sure what the author had in mind.
if( aGroup[i] == ' ' || aGroup[i] == ',' )
{
if( aMemberList )
aMemberList->push_back( EscapeString( tmp, CTX_NETNAME ) );
if( aMemberList && !tmp.IsEmpty() )
aMemberList->push_back( EscapeString( tmp, CTX_NETNAME ) );
tmp.Clear();
continue;

View File

@ -2375,6 +2375,12 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH
SCH_ITEM* bus_wire = nullptr;
wxString bus_name;
if( !aSubgraph->m_driver_connection )
{
// Incomplete bus entry. Let the unconnected tests handle it.
return true;
}
for( auto item : aSubgraph->m_items )
{
switch( item->Type() )
@ -2632,7 +2638,7 @@ bool CONNECTION_GRAPH::ercCheckFloatingWires( const CONNECTION_SUBGRAPH* aSubgra
if( aSubgraph->m_driver )
return true;
std::vector<SCH_LINE*> wires;
std::vector<SCH_ITEM*> wires;
// We've gotten this far, so we know we have no valid driver. All we need to do is check
// for a wire that we can place the error on.
@ -2640,7 +2646,9 @@ bool CONNECTION_GRAPH::ercCheckFloatingWires( const CONNECTION_SUBGRAPH* aSubgra
for( SCH_ITEM* item : aSubgraph->m_items )
{
if( item->Type() == SCH_LINE_T && item->GetLayer() == LAYER_WIRE )
wires.emplace_back( static_cast<SCH_LINE*>( item ) );
wires.emplace_back( item );
else if( item->Type() == SCH_BUS_WIRE_ENTRY_T )
wires.emplace_back( item );
}
if( !wires.empty() )
@ -2674,6 +2682,9 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
if( aSubgraph->m_no_connect )
return true;
if( !aSubgraph->m_driver_connection )
return true;
// Buses are excluded from this test: many users create buses with only a single instance
// and it's not really a problem as long as the nets in the bus pass ERC
if( aSubgraph->m_driver_connection->IsBus() )