From db4502e2aeaeead6675b2ea8909a8117780007e3 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 6 Jul 2020 12:45:57 -0400 Subject: [PATCH] Add copy ctor for BOARD_DESIGN_SETTINGS Fixes https://gitlab.com/kicad/code/kicad/-/issues/4817 --- include/board_design_settings.h | 4 ++++ pcbnew/board_design_settings.cpp | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/board_design_settings.h b/include/board_design_settings.h index a70304d693..510207c01f 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -342,11 +342,15 @@ private: wxString severityToString( const SEVERITY& aSeverity ); + void initFromOther( const BOARD_DESIGN_SETTINGS& aOther ); + public: BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); virtual ~BOARD_DESIGN_SETTINGS(); + BOARD_DESIGN_SETTINGS( const BOARD_DESIGN_SETTINGS& aOther); + BOARD_DESIGN_SETTINGS& operator=( const BOARD_DESIGN_SETTINGS& aOther ); bool LoadFromFile( const std::string& aDirectory = "" ) override; diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 3a5963e05f..60fec8ff88 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -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 ) +{ + 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. 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::begin( m_TextUpright ) ); - - return *this; }