Symbol Library Editor: do not leave the old part after renaming
This commit is contained in:
parent
019eed0d28
commit
ee140ce6c8
|
@ -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( LibraryExists( aLibrary ), false );
|
||||||
wxCHECK( aPart, false );
|
wxCHECK( aPart, false );
|
||||||
const wxString partName = aOldName.IsEmpty() ? aPart->GetName() : aOldName;
|
|
||||||
LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary );
|
LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary );
|
||||||
auto partBuf = libBuf.GetBuffer( partName );
|
auto partBuf = libBuf.GetBuffer( aPart->GetName() );
|
||||||
LIB_PART* partCopy = new LIB_PART( *aPart, nullptr );
|
LIB_PART* partCopy = new LIB_PART( *aPart, nullptr );
|
||||||
|
|
||||||
if( partBuf )
|
if( partBuf )
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
* The library buffer creates a copy of the part.
|
* 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.
|
* 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.
|
* Removes the part from the part buffer.
|
||||||
|
|
|
@ -1146,7 +1146,10 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
|
||||||
m_drawSpecificUnit = GetCurPart()->UnitsLocked() ? true : false;
|
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();
|
UpdateAliasSelectList();
|
||||||
UpdatePartSelectList();
|
UpdatePartSelectList();
|
||||||
|
|
|
@ -166,8 +166,10 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
|
||||||
if( !parent->HasAlias( m_aliasName ) )
|
if( !parent->HasAlias( m_aliasName ) )
|
||||||
m_aliasName = newFieldValue;
|
m_aliasName = newFieldValue;
|
||||||
|
|
||||||
//m_libMgr->RemovePart( fieldText, lib );
|
if( newFieldValue != fieldText )
|
||||||
m_libMgr->UpdatePart( parent, lib, fieldText );
|
m_libMgr->RemovePart( fieldText, lib );
|
||||||
|
|
||||||
|
m_libMgr->UpdatePart( parent, lib );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue