Only update value on rename if it previously matched the symbol name.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15621
This commit is contained in:
parent
a7ae4d8e9a
commit
ee724f6a2b
|
@ -390,23 +390,25 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent )
|
|||
|
||||
wxString newName = dlg.GetSymbolName();
|
||||
wxString oldName = symbolName;
|
||||
LIB_SYMBOL* libSymbol = nullptr;
|
||||
LIB_SYMBOL* libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
|
||||
bool isCurrentSymbol = editFrame->IsCurrentSymbol( libId );
|
||||
|
||||
if( editFrame->IsCurrentSymbol( libId ) )
|
||||
{
|
||||
// Update buffered copy
|
||||
libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
|
||||
libSymbol->SetName( newName );
|
||||
|
||||
libSymbol->SetName( newName );
|
||||
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
|
||||
|
||||
libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
|
||||
libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
|
||||
libMgr.SetSymbolModified( newName, libName );
|
||||
|
||||
// Now update canvasy copy
|
||||
if( isCurrentSymbol )
|
||||
{
|
||||
libSymbol = editFrame->GetCurSymbol();
|
||||
|
||||
libSymbol->SetName( newName );
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
|
||||
|
||||
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
|
||||
|
||||
editFrame->RebuildView();
|
||||
editFrame->OnModify();
|
||||
|
@ -415,16 +417,6 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent )
|
|||
// invalidate the view pointers by rebuilting the field table
|
||||
editFrame->UpdateMsgPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
|
||||
|
||||
libSymbol->SetName( newName );
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
|
||||
|
||||
libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
|
||||
libMgr.SetSymbolModified( newName, libName );
|
||||
}
|
||||
|
||||
wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
|
||||
editFrame->UpdateLibraryTree( treeItem, libSymbol );
|
||||
|
|
Loading…
Reference in New Issue