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.