From dd1a7627f8f7faaf76863b6bffb183a2624057ff Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 30 May 2020 10:33:05 -0400 Subject: [PATCH] Move setting derived symbol field properties from parent symbol. In order allow the new file format to support derived symbols with field properties that are different than the parent symbol, the code that copied the parent field properties to the derive symbol field properties had to moved out of LIB_PART::SetParent() into the legacy symbol library plugin and the symbol library editor add new symbol code to preserve the current behavior and not overwrite derived symbol field properties. This lays the ground work for allowing field properties of derived symbols to be different than their parent symbol. --- eeschema/class_libentry.cpp | 28 ---------------------------- eeschema/libedit/libedit.cpp | 20 ++++++++++++++++++++ eeschema/sch_legacy_plugin.cpp | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index e19ab5f7a0..beb56aec47 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -319,37 +319,9 @@ void LIB_PART::SetName( const wxString& aName ) void LIB_PART::SetParent( LIB_PART* aParent ) { if( aParent ) - { m_parent = aParent->SharedPtr(); - - // Inherit the parent mandatory field attributes. - for( int id=0; idGetField( id ); - - wxASSERT( parentField ); - - wxString name = field->GetText(); - - *field = *parentField; - - if( id == VALUE ) - field->SetText( name ); - else if( id == DATASHEET && !GetDocFileName().IsEmpty() ) - field->SetText( GetDocFileName() ); - - field->SetParent( this ); - } - } else - { m_parent.reset(); - } } diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index 2f4da35401..b73e5eaa56 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -360,6 +360,26 @@ void LIB_EDIT_FRAME::CreateNewPart() LIB_PART* parent = m_libMgr->GetAlias( parentSymbolName, lib ); wxCHECK( parent, /* void */ ); new_part.SetParent( parent ); + + // Inherit the parent mandatory field attributes. + for( int id=0; idGetField( id ); + + wxCHECK( parentField, /* void */ ); + + *field = *parentField; + + if( id == VALUE ) + field->SetText( name ); + + field->SetParent( &new_part ); + } } m_libMgr->UpdatePart( &new_part, lib ); diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 500d259806..9b21a7cc3a 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -2965,6 +2965,26 @@ void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr& aPart, { LIB_PART* newPart = new LIB_PART( newAliasName ); + // Inherit the parent mandatory field attributes. + for( int id=0; idGetField( id ); + + // the MANDATORY_FIELDS are exactly that in RAM. + wxASSERT( field ); + + LIB_FIELD* parentField = aPart->GetField( id ); + + wxASSERT( parentField ); + + *field = *parentField; + + if( id == VALUE ) + field->SetText( newAliasName ); + + field->SetParent( newPart ); + } + newPart->SetParent( aPart.get() ); // This will prevent duplicate aliases.