libedit: field edition should be undoable

This commit is contained in:
Tomasz Włostowski 2017-11-13 18:21:23 +01:00 committed by Maciej Suminski
parent f2257ccccc
commit 72de4e1857
2 changed files with 9 additions and 3 deletions

View File

@ -107,6 +107,8 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
delete lastcmd; delete lastcmd;
part = (LIB_PART*) wrapper.GetItem(); part = (LIB_PART*) wrapper.GetItem();
printf("RestoreCopy [%p]\n", part);
// Do not delete the previous part by calling SetCurPart( part ), // Do not delete the previous part by calling SetCurPart( part ),
// which calls delete <previous part>. // which calls delete <previous part>.
// <previous part> is now put in redo list and is owned by this list. // <previous part> is now put in redo list and is owned by this list.

View File

@ -74,11 +74,13 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
newFieldValue = dlg.GetText(); newFieldValue = dlg.GetText();
wxString fieldText = aField->GetFullText( m_unit ); wxString fieldText = aField->GetFullText( m_unit );
bool creatingNewComponent = aField->GetId() == VALUE && newFieldValue != aField->GetText();
/* If the value field is changed, this is equivalent to creating a new component from /* If the value field is changed, this is equivalent to creating a new component from
* the old one. Rename the component and remove any conflicting aliases to prevent name * the old one. Rename the component and remove any conflicting aliases to prevent name
* errors when updating the library. * errors when updating the library.
*/ */
if( aField->GetId() == VALUE && newFieldValue != aField->GetText() ) if( creatingNewComponent )
{ {
wxString msg; wxString msg;
wxString lib = GetCurLib(); wxString lib = GetCurLib();
@ -168,11 +170,13 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
m_libMgr->UpdatePart( parent, lib, fieldText ); m_libMgr->UpdatePart( parent, lib, fieldText );
} }
dlg.UpdateField( aField );
if( !aField->InEditMode() ) if( !aField->InEditMode() && !creatingNewComponent )
{
SaveCopyInUndoList( parent ); SaveCopyInUndoList( parent );
}
dlg.UpdateField( aField );
m_canvas->Refresh(); m_canvas->Refresh();
OnModify(); OnModify();