diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index eaca9bdf87..f5a49aa88f 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -35,6 +35,7 @@ #include #include #include +#include void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) @@ -42,14 +43,12 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) wxString newFieldValue; wxString title; wxString caption; - wxString oldName; if( aField == NULL ) return; LIB_PART* parent = aField->GetParent(); - - wxASSERT( parent ); + wxCHECK( parent, /* void */ ); // Editing the component value field is equivalent to creating a new component based // on the current component. Set the dialog message to inform the user. @@ -85,7 +84,7 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) wxString lib = GetCurLib(); // Test the current library for name conflicts. - if( !lib.empty() && Prj().SchSymbolLibTable()->LoadSymbol( lib, newFieldValue ) ) + if( !lib.empty() && m_libMgr->PartExists( newFieldValue, lib ) ) { msg.Printf( _( "The name '%s' conflicts with an existing entry in the component library '%s'.\n\n" @@ -124,7 +123,7 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) bool conflicts = false; wxArrayString libAliasNames, symbolAliasNames; - Prj().SchSymbolLibTable()->EnumerateSymbolLib( lib, libAliasNames ); + libAliasNames = m_libMgr->GetAliasNames( lib ); symbolAliasNames = parent->GetAliasNames(); for( size_t i = 0; i < symbolAliasNames.GetCount(); i++ ) @@ -156,7 +155,7 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) for( size_t i = 0; i < aliases.GetCount(); i++ ) { - if( Prj().SchSymbolLibTable()->LoadSymbol( lib, aliases[ i ] ) != NULL ) + if( m_libMgr->GetAlias( aliases[i], lib ) != NULL ) parent->RemoveAlias( aliases[ i ] ); } } @@ -164,6 +163,9 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) if( !parent->HasAlias( m_aliasName ) ) m_aliasName = newFieldValue; + + //m_libMgr->RemovePart( fieldText, lib ); + m_libMgr->UpdatePart( parent, lib, fieldText ); } dlg.UpdateField( aField );