From fb225acefcf565fd6bc07dba0f979d4532beb73e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 5 Feb 2023 18:41:00 +0100 Subject: [PATCH] Eeschema, ExportSymbolsToLibrary(): fix not working replace library. When exporting symbols of the schematic to a new library, if this library exists the dialog ask for overwriting it, but it did not work. Fixed now. --- eeschema/tools/sch_editor_control.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 549cbaa3b9..8e73890638 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -391,11 +391,16 @@ int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent ) return 0; } + // if the "new" library is in fact an existing library and the used asked for replacing + // it by the recreated lib, erase it: + if( fn.FileExists() ) + wxRemoveFile( fn.GetFullPath() ); + if( !mgr.CreateLibrary( fn.GetFullPath(), libTable ) ) { - DisplayError( m_frame, wxString::Format( _( "Could not add library '%s'." ), + DisplayError( m_frame, wxString::Format( _( "Could not add library '%s'." ), targetLib ) ); - return 0; + return 0; } } else