diff --git a/common/embedded_files.cpp b/common/embedded_files.cpp index 97fd9decd3..c134ad5d14 100644 --- a/common/embedded_files.cpp +++ b/common/embedded_files.cpp @@ -591,6 +591,21 @@ EMBEDDED_FILES::EMBEDDED_FILES( const EMBEDDED_FILES& other ) : } +EMBEDDED_FILES::EMBEDDED_FILES( const EMBEDDED_FILES& other, bool aDeepCopy ) : + m_embedFonts( other.m_embedFonts ) +{ + if( aDeepCopy ) + { + for( const auto& [name, file] : other.m_files ) + m_files[name] = new EMBEDDED_FILE( *file ); + + m_fontFiles = other.m_fontFiles; + } + + m_fileAddedCallback = other.m_fileAddedCallback; +} + + // Copy assignment operator EMBEDDED_FILES& EMBEDDED_FILES::operator=( const EMBEDDED_FILES& other ) { diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index caba783727..3f5cf8b082 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -165,9 +165,10 @@ LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB* } -LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) : +LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary, + bool aCopyEmbeddedFiles ) : SYMBOL( aSymbol ), - EMBEDDED_FILES( aSymbol ), + EMBEDDED_FILES( aSymbol, aCopyEmbeddedFiles ), m_me( this, null_deleter() ) { m_library = aLibrary; diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 2a667d260a..341f866eb2 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -84,7 +84,8 @@ public: LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr, SYMBOL_LIB* aLibrary = nullptr ); - LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary = nullptr ); + LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary = nullptr, + bool aCopyEmbeddedFiles = true ); virtual ~LIB_SYMBOL() {} diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 5095c99a8c..29dae54599 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2091,7 +2091,8 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) std::vector originalPins = originalSymbol->GetPins( unit, bodyStyle ); // Copy the source so we can re-orient and translate it. - LIB_SYMBOL tempSymbol( *originalSymbol ); + LIB_SYMBOL tempSymbol( *originalSymbol, nullptr, false ); + std::vector tempPins = tempSymbol.GetPins( unit, bodyStyle ); tempSymbol.SetFlags( aSymbol->GetFlags() ); @@ -2219,6 +2220,7 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) m_gal->SetFillColor( marker_color ); m_gal->DrawCurve( left, top, bottom, right, 1 ); } + } diff --git a/include/embedded_files.h b/include/embedded_files.h index 1c7e08d8ca..8a79d5a25e 100644 --- a/include/embedded_files.h +++ b/include/embedded_files.h @@ -103,6 +103,7 @@ public: EMBEDDED_FILES( EMBEDDED_FILES&& other ) noexcept; EMBEDDED_FILES( const EMBEDDED_FILES& other ); + EMBEDDED_FILES( const EMBEDDED_FILES& other, bool aDeepCopy ); ~EMBEDDED_FILES() {