diff --git a/eeschema/lib_manager.cpp b/eeschema/lib_manager.cpp index 896c28afe5..53bd07d92e 100644 --- a/eeschema/lib_manager.cpp +++ b/eeschema/lib_manager.cpp @@ -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 ) diff --git a/eeschema/lib_manager.h b/eeschema/lib_manager.h index 951b91bb62..45974feeee 100644 --- a/eeschema/lib_manager.h +++ b/eeschema/lib_manager.h @@ -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. diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 6a52cc942f..c29cb66072 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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(); diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index c4fdb2ecc0..3839572576 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -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 ); }