Symbol Library Editor: do not leave the old part after renaming

This commit is contained in:
Maciej Suminski 2018-01-09 09:37:31 +01:00
parent 019eed0d28
commit ee140ce6c8
4 changed files with 11 additions and 7 deletions

View File

@ -338,13 +338,12 @@ SCH_SCREEN* LIB_MANAGER::GetScreen( const wxString& aAlias, const wxString& aLib
}
bool LIB_MANAGER::UpdatePart( LIB_PART* aPart, const wxString& aLibrary, wxString aOldName )
bool LIB_MANAGER::UpdatePart( LIB_PART* aPart, const wxString& aLibrary )
{
wxCHECK( LibraryExists( aLibrary ), false );
wxCHECK( aPart, false );
const wxString partName = aOldName.IsEmpty() ? aPart->GetName() : aOldName;
LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary );
auto partBuf = libBuf.GetBuffer( partName );
auto partBuf = libBuf.GetBuffer( aPart->GetName() );
LIB_PART* partCopy = new LIB_PART( *aPart, nullptr );
if( partBuf )

View File

@ -100,7 +100,7 @@ public:
* The library buffer creates a copy of the part.
* It is required to save the library to use the updated part in the schematic editor.
*/
bool UpdatePart( LIB_PART* aPart, const wxString& aLibrary, wxString aOldName = wxEmptyString );
bool UpdatePart( LIB_PART* aPart, const wxString& aLibrary );
/**
* Removes the part from the part buffer.

View File

@ -1146,7 +1146,10 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
m_drawSpecificUnit = GetCurPart()->UnitsLocked() ? true : false;
}
m_libMgr->UpdatePart( GetCurPart(), GetCurLib(), oldName );
if( oldName != GetCurPart()->GetName() )
m_libMgr->RemovePart( GetCurLib(), oldName );
m_libMgr->UpdatePart( GetCurPart(), GetCurLib() );
UpdateAliasSelectList();
UpdatePartSelectList();

View File

@ -166,8 +166,10 @@ 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 );
if( newFieldValue != fieldText )
m_libMgr->RemovePart( fieldText, lib );
m_libMgr->UpdatePart( parent, lib );
}