Fix null graph in some connections

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4747
This commit is contained in:
Jon Evans 2020-06-29 20:27:08 -04:00
parent e91b7cf18f
commit 8a0277eb2e
4 changed files with 15 additions and 19 deletions

View File

@ -305,10 +305,7 @@ void CONNECTION_SUBGRAPH::UpdateItemConnections()
SCH_CONNECTION* item_conn = item->Connection( m_sheet );
if( !item_conn )
{
item_conn = item->InitializeConnection( m_sheet );
item_conn->SetGraph( m_graph );
}
item_conn = item->InitializeConnection( m_sheet, m_graph );
if( ( m_driver_connection->IsBus() && item_conn->IsNet() ) ||
( m_driver_connection->IsNet() && item_conn->IsBus() ) )
@ -444,7 +441,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
{
if( !pin->Connection( aSheet ) )
pin->InitializeConnection( aSheet )->SetGraph( this );
pin->InitializeConnection( aSheet, this );
pin->ConnectedItems( aSheet ).clear();
pin->Connection( aSheet )->Reset();
@ -466,7 +463,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
for( SCH_PIN* pin : component->GetSchPins( &aSheet ) )
{
pin->InitializeConnection( aSheet )->SetGraph( this );
pin->InitializeConnection( aSheet, this );
wxPoint pos = pin->GetPosition();
@ -486,8 +483,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
else
{
m_items.insert( item );
auto conn = item->InitializeConnection( aSheet );
conn->SetGraph( this );
auto conn = item->InitializeConnection( aSheet, this );
// Set bus/net property here so that the propagation code uses it
switch( item->Type() )
@ -688,10 +684,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
auto* conn = aItem->Connection( sheet );
if( !conn )
{
conn = aItem->InitializeConnection( sheet );
conn->SetGraph( this );
}
conn = aItem->InitializeConnection( sheet, this );
return ( conn->SubgraphCode() == 0 );
};
@ -936,10 +929,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
SCH_CONNECTION* connection = pin->Connection( sheet );
if( !connection )
{
connection = pin->InitializeConnection( sheet );
connection->SetGraph( this );
}
connection = pin->InitializeConnection( sheet, this );
// If this pin already has a subgraph, don't need to process
if( connection->SubgraphCode() > 0 )

View File

@ -167,6 +167,7 @@ void SCH_CONNECTION::ConfigureFromLabel( const wxString& aLabel )
{
auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
member->SetPrefix( prefix );
member->SetGraph( m_graph );
member->ConfigureFromLabel( alias_member );
m_members.push_back( member );
}
@ -175,6 +176,7 @@ void SCH_CONNECTION::ConfigureFromLabel( const wxString& aLabel )
{
auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
member->SetPrefix( prefix );
member->SetGraph( m_graph );
member->ConfigureFromLabel( group_member );
m_members.push_back( member );
}
@ -764,4 +766,4 @@ bool SCH_CONNECTION::IsMemberOfBus( SCH_CONNECTION* aOther ) const
return true;
return false;
}
}

View File

@ -166,7 +166,8 @@ void SCH_ITEM::AddConnectionTo( const SCH_SHEET_PATH& aSheet, SCH_ITEM* aItem )
}
SCH_CONNECTION* SCH_ITEM::InitializeConnection( const SCH_SHEET_PATH& aSheet )
SCH_CONNECTION* SCH_ITEM::InitializeConnection( const SCH_SHEET_PATH& aSheet,
CONNECTION_GRAPH* aGraph )
{
if( Connection( aSheet ) )
{
@ -178,6 +179,8 @@ SCH_CONNECTION* SCH_ITEM::InitializeConnection( const SCH_SHEET_PATH& aSheet )
auto connection = new SCH_CONNECTION( this );
connection->SetSheet( aSheet );
m_connection_map.insert( std::make_pair( aSheet, connection ) );
connection->SetGraph( aGraph );
return connection;
}

View File

@ -38,6 +38,7 @@
#include <sch_sheet_path.h>
#include <render_settings.h>
class CONNECTION_GRAPH;
class SCH_CONNECTION;
class SCH_SHEET_PATH;
class SCHEMATIC;
@ -414,7 +415,7 @@ public:
*
* @param aPath is the sheet path to initialize
*/
SCH_CONNECTION* InitializeConnection( const SCH_SHEET_PATH& aPath );
SCH_CONNECTION* InitializeConnection( const SCH_SHEET_PATH& aPath, CONNECTION_GRAPH* aGraph );
/**
* Returns true if this item should propagate connection info to aItem