From 72de4e18577c6e950a1050ccd71330956640e24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Mon, 13 Nov 2017 18:21:23 +0100 Subject: [PATCH] libedit: field edition should be undoable --- eeschema/libedit_undo_redo.cpp | 2 ++ eeschema/libfield.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index 2774569c9d..1f340259ef 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -107,6 +107,8 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) delete lastcmd; part = (LIB_PART*) wrapper.GetItem(); + printf("RestoreCopy [%p]\n", part); + // Do not delete the previous part by calling SetCurPart( part ), // which calls delete . // is now put in redo list and is owned by this list. diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index f5a49aa88f..5e11226aa3 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -74,11 +74,13 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) newFieldValue = dlg.GetText(); 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 * the old one. Rename the component and remove any conflicting aliases to prevent name * errors when updating the library. */ - if( aField->GetId() == VALUE && newFieldValue != aField->GetText() ) + if( creatingNewComponent ) { wxString msg; wxString lib = GetCurLib(); @@ -168,11 +170,13 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) m_libMgr->UpdatePart( parent, lib, fieldText ); } - dlg.UpdateField( aField ); - if( !aField->InEditMode() ) + if( !aField->InEditMode() && !creatingNewComponent ) + { SaveCopyInUndoList( parent ); + } + dlg.UpdateField( aField ); m_canvas->Refresh(); OnModify();