Fix importing of legacy netclasses

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13746
This commit is contained in:
Jon Evans 2023-02-02 08:29:12 -05:00
parent ab0c4dd292
commit 200bf696af
2 changed files with 15 additions and 5 deletions

View File

@ -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<NET_SETTINGS> legacySettings = GetDesignSettings().m_NetSettings;
project.NetSettings()->m_DefaultNetClass = legacySettings->m_DefaultNetClass;
project.NetSettings()->m_NetClasses = legacySettings->m_NetClasses;
std::shared_ptr<NET_SETTINGS> legacySettings = GetDesignSettings().m_NetSettings;
std::shared_ptr<NET_SETTINGS>& 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.

View File

@ -2442,7 +2442,9 @@ void PCB_PARSER::parseNETCLASS()
NeedRIGHT();
}
if( m_board->GetDesignSettings().m_NetSettings->m_NetClasses.count( nc->GetName() ) )
std::shared_ptr<NET_SETTINGS>& 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;
}
}