From 8aff923710dcf45f187db50f151c88e7715dc83e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 11 Jan 2023 16:04:24 -0800 Subject: [PATCH] Set dirty bit and handle undo for export remap When remapping the exported symbols, we should keep this in the undo stack (remapping, not the existence of the new elements) and set the dirty bit for the file to ensure it is saved/autosaved Fixes https://gitlab.com/kicad/code/kicad/issues/13493 --- eeschema/tools/sch_editor_control.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 6cf61be251..a2ece44d80 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -413,6 +413,7 @@ int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent ) return 0; bool map = IsOK( m_frame, _( "Update symbols in schematic to refer to new library?" ) ); + bool append = false; SYMBOL_LIB_TABLE_ROW* row = mgr.GetLibrary( targetLib ); SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::EnumFromStr( row->GetType() ); @@ -433,11 +434,19 @@ int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent ) LIB_ID id = it.first; id.SetLibNickname( targetLib ); + for( SCH_SYMBOL* symbol : symbolMap[it.first] ) + { + m_frame->SaveCopyInUndoList( m_frame->GetScreen(), symbol, UNDO_REDO::CHANGED, append, false); symbol->SetLibId( id ); + append = true; + } } } + if( append ) + m_frame->OnModify(); + return 0; }