From 23fab89131187bcb234b2a26e3b9573fa19490cc Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 16 Sep 2023 12:42:48 -0700 Subject: [PATCH] Properly handle incremental bus connections - Incremental extraction needs the newly created items. The modified items are already set in the connection graph but the newly created items don't exist yet, so we need to add those explicitly - Bus parents need to ensure that the bus children exist because we iterate on the updates from the top of the graph down (cherry picked from commit 9fc45eb08cbae759bd6f6e69130a7dffcf4e00d4) --- eeschema/connection_graph.cpp | 21 ++++++++++++++++++++- eeschema/sch_edit_frame.cpp | 11 +++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 66ffff7b77..c4b2fb6874 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 ); @@ -599,8 +606,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 ) @@ -658,11 +668,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 ); @@ -2212,6 +2228,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 557886f7c5..6534a06702 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1496,9 +1496,10 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) } 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 ) { @@ -1507,11 +1508,16 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) 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 ) @@ -1546,6 +1552,8 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items ); + all_items.insert( item_paths.begin(), item_paths.end() ); + CONNECTION_GRAPH new_graph( &Schematic() ); new_graph.SetLastCodes( Schematic().ConnectionGraph() ); @@ -1556,7 +1564,6 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) { case SCH_FIELD_T: case SCH_PIN_T: - case SCH_SHEET_PIN_T: static_cast( item->GetParent() )->SetConnectivityDirty(); break;