Symbol Editor: Allow changing parent for derived symbol

The symbol editor did not actually update the parent symbol when the
dropdown in the properties editor was changed. This fixes that defect.

Signed-off-by: Kevin Lannen <kevin.lannen@gmail.com>
This commit is contained in:
Kevin Lannen 2020-07-19 21:17:08 -06:00 committed by Wayne Stambaugh
parent 9cdada9eb4
commit 13f9478a76
1 changed files with 33 additions and 0 deletions

View File

@ -249,6 +249,19 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::Validate()
}
}
// Verify that the parent name is set if the symbol is inherited
if( m_libEntry->IsAlias() )
{
wxString parentName = m_inheritanceSelectCombo->GetValue();
if( parentName.IsEmpty() )
{
m_delayedErrorMessage = _( "Aliased symbol must have a parent selected" );
return false;
}
}
if( m_SelNumberOfUnits->GetValue() < m_libEntry->GetUnitCount() )
{
if( !IsOK( this, _( "Delete extra units from symbol?" ) ) )
@ -311,6 +324,26 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataFromWindow()
m_libEntry->SetFields( *m_fields );
// Update the parent for inherited symbols
if( m_libEntry->IsAlias() )
{
wxString parentName = m_inheritanceSelectCombo->GetValue();
// The parentName was verified to be non-empty in the Validator
wxString libName = m_Parent->GetCurLib();
// Get the parent from the libManager based on the name set in the inheritance combo box.
LIB_PART* newParent = m_Parent->GetLibManager().GetAlias( parentName, libName );
// Verify that the requested parent exists
wxCHECK( newParent, false );
// Verify that the new parent is not an alias.
wxCHECK( !newParent->IsAlias(), false );
m_libEntry->SetParent( newParent );
}
// We need to keep the name and the value the same at the moment!
m_libEntry->SetName( newName );
m_libEntry->SetDescription( m_DescCtrl->GetValue() );