Ensure merged buses have all members
This commit is contained in:
parent
df16ea25a8
commit
13baf548ca
|
@ -112,8 +112,15 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
|
|||
{
|
||||
// For all other driver types, sort by name
|
||||
std::sort( candidates.begin(), candidates.end(),
|
||||
[&] ( SCH_ITEM* a, SCH_ITEM* b) -> bool
|
||||
[&]( SCH_ITEM* a, SCH_ITEM* b ) -> bool
|
||||
{
|
||||
SCH_CONNECTION* ac = a->Connection( m_sheet );
|
||||
SCH_CONNECTION* bc = b->Connection( m_sheet );
|
||||
|
||||
// Ensure we don't pick the subset over the superset
|
||||
if( ac->IsBus() && bc->IsBus() )
|
||||
return bc->IsSubsetOf( ac );
|
||||
|
||||
return GetNameForDriver( a ) < GetNameForDriver( b );
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -739,27 +739,16 @@ wxString SCH_CONNECTION::PrintBusForUI( const wxString& aGroup )
|
|||
|
||||
bool SCH_CONNECTION::IsSubsetOf( SCH_CONNECTION* aOther ) const
|
||||
{
|
||||
if( aOther->IsNet() )
|
||||
return IsNet() ? ( aOther->Name( true ) == Name( true ) ) : false;
|
||||
|
||||
if( !IsBus() )
|
||||
if( !aOther->IsBus() )
|
||||
return false;
|
||||
|
||||
std::vector<wxString> mine, theirs;
|
||||
for( const auto& member : aOther->Members() )
|
||||
{
|
||||
if( member->FullLocalName() == FullLocalName() )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( const auto& m : Members() )
|
||||
mine.push_back( m->Name( true ) );
|
||||
|
||||
for( const auto& m : aOther->Members() )
|
||||
theirs.push_back( m->Name( true ) );
|
||||
|
||||
std::set<wxString> subset;
|
||||
|
||||
std::set_intersection( mine.begin(), mine.end(),
|
||||
theirs.begin(), theirs.end(),
|
||||
std::inserter(subset, subset.begin() ) );
|
||||
|
||||
return ( !subset.empty() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -263,12 +263,8 @@ public:
|
|||
static wxString PrintBusForUI( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Returns true if aOther is a subset of this connection or vice versa.
|
||||
*
|
||||
* For plain nets, this just tests whether or not the connectio names are
|
||||
* the same. For buses, this tests whether the two have any shared members.
|
||||
*
|
||||
* Will always return false if one connection is a bus and the other a net.
|
||||
* Returns true if this connection is contained within aOther (but not the same as aOther)
|
||||
* @return true if this connection is a member of aOther
|
||||
*/
|
||||
bool IsSubsetOf( SCH_CONNECTION* aOther ) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue