diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 02e5b39325..e91208bd8e 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1030,7 +1030,8 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter ) } } - symbol->SetLibSymbol( libSymbol.release() ); + if( libSymbol.get() ) // Only change the old link if the new link exists + symbol->SetLibSymbol( libSymbol.release() ); } // Changing the symbol may adjust the bbox of the symbol. This re-inserts the diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 2624dbcc53..166f6fb0d2 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -332,10 +332,12 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent ) { + bool savePowerSymbols = IsOK( m_frame, _( "Include power symbols in schematic to the library?" ) ); + bool createNew = aEvent.IsAction( &EE_ACTIONS::exportSymbolsToNewLibrary ); SCH_REFERENCE_LIST symbols; - m_frame->Schematic().GetSheets().GetSymbols( symbols, false ); + m_frame->Schematic().GetSheets().GetSymbols( symbols, savePowerSymbols ); std::map libSymbols; std::map> symbolMap; @@ -430,7 +432,6 @@ 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); @@ -487,6 +488,7 @@ int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent ) for( SCH_SHEET_PATH& sheet : sheets ) { SCH_SCREEN* screen = sheet.LastScreen(); + if( processedScreens.find( ( screen ) ) == processedScreens.end() ) { processedScreens.insert( screen );