diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index f47227d07e..17353aa115 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -192,9 +192,13 @@ void BOARD::SetProject( PROJECT* aProject, bool aReferenceOnly ) // want to transfer it over to the project netclasses list. if( m_LegacyNetclassesLoaded ) { - std::shared_ptr legacySettings = GetDesignSettings().m_NetSettings; - project.NetSettings()->m_DefaultNetClass = legacySettings->m_DefaultNetClass; - project.NetSettings()->m_NetClasses = legacySettings->m_NetClasses; + std::shared_ptr legacySettings = GetDesignSettings().m_NetSettings; + std::shared_ptr& projectSettings = project.NetSettings(); + + projectSettings->m_DefaultNetClass = legacySettings->m_DefaultNetClass; + projectSettings->m_NetClasses = legacySettings->m_NetClasses; + projectSettings->m_NetClassPatternAssignments = + std::move( legacySettings->m_NetClassPatternAssignments ); } // Now update the DesignSettings' netclass pointer to point into the project. diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index bf96a7b828..eb6ab857b1 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -2442,7 +2442,9 @@ void PCB_PARSER::parseNETCLASS() NeedRIGHT(); } - if( m_board->GetDesignSettings().m_NetSettings->m_NetClasses.count( nc->GetName() ) ) + std::shared_ptr& netSettings = m_board->GetDesignSettings().m_NetSettings; + + if( netSettings->m_NetClasses.count( nc->GetName() ) ) { // Must have been a name conflict, this is a bad board file. // User may have done a hand edit to the file. @@ -2452,9 +2454,13 @@ void PCB_PARSER::parseNETCLASS() CurOffset() ); THROW_IO_ERROR( error ); } + else if( nc->GetName() == netSettings->m_DefaultNetClass->GetName() ) + { + netSettings->m_DefaultNetClass = nc; + } else { - m_board->GetDesignSettings().m_NetSettings->m_NetClasses[ nc->GetName() ] = nc; + netSettings->m_NetClasses[ nc->GetName() ] = nc; } }