diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 73b700a243..37d41b9320 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -233,13 +233,20 @@ void CONNECTION_SUBGRAPH::getAllConnectedItems( std::setm_absorbed_by ) + { + wxASSERT( sg->m_graph == sg->m_absorbed_by->m_graph ); sg = sg->m_absorbed_by; + } aSubgraphs.insert( sg ); aSubgraphs.insert( sg->m_absorbed_subgraphs.begin(), sg->m_absorbed_subgraphs.end() ); for( SCH_ITEM* item : sg->m_items ) + { + item->Connection( &m_sheet )->Reset(); + item->ConnectedItems( m_sheet ).clear(); aItems.emplace( m_sheet, item ); + } for( CONNECTION_SUBGRAPH* child_sg : sg->m_hier_children ) child_sg->getAllConnectedItems( aItems, aSubgraphs ); @@ -604,8 +611,11 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco for( SCH_ITEM* item : sheet.LastScreen()->Items() ) { if( item->IsConnectable() && ( aUnconditional || item->IsConnectivityDirty() ) ) + { + wxLogTrace( ConnTrace, wxT( "Adding item %s to connectivity graph update" ), + item->GetTypeDesc() ); items.push_back( item ); - + } // Ensure the hierarchy info stored in SCREENS is built and up to date // (multi-unit symbols) if( item->Type() == SCH_SYMBOL_T ) @@ -663,11 +673,17 @@ std::set> CONNECTION_GRAPH::ExtractAffected { // Find the primary subgraph on this sheet while( aSubgraph->m_absorbed_by ) + { + wxASSERT( aSubgraph->m_graph == aSubgraph->m_absorbed_by->m_graph ); aSubgraph = aSubgraph->m_absorbed_by; + } // Find the top most connected subgraph on all sheets while( aSubgraph->m_hier_parent ) + { + wxASSERT( aSubgraph->m_graph == aSubgraph->m_hier_parent->m_graph ); aSubgraph = aSubgraph->m_hier_parent; + } // Recurse through all subsheets to collect connected items aSubgraph->getAllConnectedItems( retvals, subgraphs ); @@ -2229,6 +2245,9 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo candidate->m_code, candidate->m_driver_connection->Name() ); candidate->m_hier_parent = aParent; + aParent->m_hier_children.insert( candidate ); + + wxASSERT( candidate->m_graph == aParent->m_graph ); search_list.push_back( candidate ); break; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index e5ea967068..0a343e6ca4 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1686,9 +1686,10 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL } else { - auto& changed_list = m_undoList.m_CommandsList.back(); + PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back(); std::set changed_items; std::vector pts; + std::set> item_paths; for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii ) { @@ -1697,11 +1698,16 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL if( !item || !IsEeschemaType( item->Type() ) ) continue; + SCH_SCREEN* screen = static_cast( changed_list->GetScreenForItem( ii ) ); SCH_ITEM* sch_item = static_cast( item ); + SCH_SHEET_PATHS& paths = screen->GetClientSheetPaths(); std::vector tmp_pts = sch_item->GetConnectionPoints(); pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() ); changed_items.insert( sch_item ); + + for( SCH_SHEET_PATH& path : paths ) + item_paths.insert( std::make_pair( path, sch_item ) ); } for( VECTOR2I& pt: pts ) @@ -1731,6 +1737,8 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL std::set> all_items = Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items ); + all_items.insert( item_paths.begin(), item_paths.end() ); + CONNECTION_GRAPH new_graph( &Schematic() ); new_graph.SetLastCodes( Schematic().ConnectionGraph() ); @@ -1741,7 +1749,6 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL { case SCH_FIELD_T: case SCH_PIN_T: - case SCH_SHEET_PIN_T: static_cast( item->GetParent() )->SetConnectivityDirty(); break;