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