From 26629928c33e87a22248693f5495e3f194e88eb2 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 11 Apr 2024 15:55:58 -0700 Subject: [PATCH] Incremental updates should not clear globals Netclass assignments are stored in the project level but CONNECTION_GRAPH updates would clear the assignments. This keeps existing netname->netclass assignments but updates any netnames that were changed by the incremental updates. Absolute updates are not affected and fully recreate the net name to netclass map Fixes https://gitlab.com/kicad/code/kicad/-/issues/17720 (cherry picked from commit e538b982862190c23873d07dfa6cb1a718c4880c) --- eeschema/connection_graph.cpp | 15 +++++++++++++-- eeschema/connection_graph.h | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 99b24bc707..f992498c4f 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -689,7 +689,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco PROF_TIMER build_graph( "buildConnectionGraph" ); - buildConnectionGraph( aChangedItemHandler ); + buildConnectionGraph( aChangedItemHandler, aUnconditional ); if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) ) build_graph.Show(); @@ -1928,7 +1928,7 @@ void CONNECTION_GRAPH::processSubGraphs() // on some portion of the items. -void CONNECTION_GRAPH::buildConnectionGraph( std::function* aChangedItemHandler ) +void CONNECTION_GRAPH::buildConnectionGraph( std::function* aChangedItemHandler, bool aUnconditional ) { // Recache all bus aliases for later use wxCHECK_RET( m_schematic, wxT( "Connection graph cannot be built without schematic pointer" ) ); @@ -2286,6 +2286,17 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function* a for( const auto& [ netname, subgraphs ] : m_net_name_to_subgraphs_map ) checkNetclassDrivers( subgraphs ); + + if( !aUnconditional ) + { + for( auto& [ netname, netclass ] : oldAssignments ) + { + if( netSettings->m_NetClassLabelAssignments.count( netname ) ) + continue; + + netSettings->m_NetClassLabelAssignments[ netname ] = netclass; + } + } } diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index e025a8937d..884f09b1b4 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -499,8 +499,12 @@ private: * the driver is first selected by CONNECTION_SUBGRAPH::ResolveDrivers(), * and then the connection for the chosen driver is propagated to all the * other items in the subgraph. + * + * If the unconitional flag is set, all existing net classes will be removed + * and re-created. Otherwise, we will preserve existing net classes that do not + * conflict with the new net classes. */ - void buildConnectionGraph( std::function* aChangedItemHandler ); + void buildConnectionGraph( std::function* aChangedItemHandler, bool aUnconditional ); /** * Generate individual item subgraphs on a per-sheet basis.