Add copy ctor for BOARD_DESIGN_SETTINGS

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4817
This commit is contained in:
Jon Evans 2020-07-06 12:45:57 -04:00
parent 4e54b773e9
commit db4502e2ae
2 changed files with 20 additions and 2 deletions

View File

@ -342,11 +342,15 @@ private:
wxString severityToString( const SEVERITY& aSeverity ); wxString severityToString( const SEVERITY& aSeverity );
void initFromOther( const BOARD_DESIGN_SETTINGS& aOther );
public: public:
BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
virtual ~BOARD_DESIGN_SETTINGS(); virtual ~BOARD_DESIGN_SETTINGS();
BOARD_DESIGN_SETTINGS( const BOARD_DESIGN_SETTINGS& aOther);
BOARD_DESIGN_SETTINGS& operator=( const BOARD_DESIGN_SETTINGS& aOther ); BOARD_DESIGN_SETTINGS& operator=( const BOARD_DESIGN_SETTINGS& aOther );
bool LoadFromFile( const std::string& aDirectory = "" ) override; bool LoadFromFile( const std::string& aDirectory = "" ) override;

View File

@ -569,7 +569,23 @@ BOARD_DESIGN_SETTINGS::~BOARD_DESIGN_SETTINGS()
} }
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( const BOARD_DESIGN_SETTINGS& aOther ) :
NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aOther.m_parent,
aOther.m_path ),
m_Pad_Master( nullptr )
{
initFromOther( aOther );
}
BOARD_DESIGN_SETTINGS& BOARD_DESIGN_SETTINGS::operator=( const BOARD_DESIGN_SETTINGS& aOther ) BOARD_DESIGN_SETTINGS& BOARD_DESIGN_SETTINGS::operator=( const BOARD_DESIGN_SETTINGS& aOther )
{
initFromOther( aOther );
return *this;
}
void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther )
{ {
// Copy of NESTED_SETTINGS around is not allowed, so let's just update the params. // Copy of NESTED_SETTINGS around is not allowed, so let's just update the params.
m_TrackWidthList = aOther.m_TrackWidthList; m_TrackWidthList = aOther.m_TrackWidthList;
@ -617,8 +633,6 @@ BOARD_DESIGN_SETTINGS& BOARD_DESIGN_SETTINGS::operator=( const BOARD_DESIGN_SETT
std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ), std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ),
std::begin( m_TextUpright ) ); std::begin( m_TextUpright ) );
return *this;
} }