Eeschema: fix project rescue bug.

When a rescue library already existed, the disabled writing of legacy
symbol library table entries prevented the rescue library from being
updated.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/11897

(cherry picked from commit 4e7b5b9784)
This commit is contained in:
Wayne Stambaugh 2022-06-28 15:04:09 -04:00
parent 87d4249d9f
commit b7b955e37b
1 changed files with 35 additions and 17 deletions

View File

@ -675,7 +675,7 @@ void LEGACY_RESCUER::OpenRescueLibrary()
m_rescue_lib->EnableBuffering();
// If a rescue library already exists copy the contents of that library so we do not
// lose an previous rescues.
// lose any previous rescues.
SYMBOL_LIB* rescueLib = m_prj->SchLibs()->FindLibrary( fn.GetName() );
if( rescueLib )
@ -810,6 +810,27 @@ void SYMBOL_LIB_TABLE_RESCUER::OpenRescueLibrary()
{
m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
(*m_properties)[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
wxFileName fn = GetRescueLibraryFileName( m_schematic );
// If a rescue library already exists copy the contents of that library so we do not
// lose any previous rescues.
if( m_prj->SchSymbolLibTable()->HasLibrary( fn.GetName() ) )
{
std::vector<LIB_SYMBOL*> symbols;
try
{
m_prj->SchSymbolLibTable()->LoadSymbolLib( symbols, fn.GetName() );
}
catch( ... /* IO_ERROR */ )
{
return;
}
for( LIB_SYMBOL* symbol : symbols )
AddSymbol( symbol );
}
}
@ -818,10 +839,6 @@ bool SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary( wxWindow *aParent )
wxString msg;
wxFileName fn = GetRescueLibraryFileName( m_schematic );
// If the rescue library already exists in the symbol library table no need save it to add
// it to the table.
if( !m_prj->SchSymbolLibTable()->HasLibrary( fn.GetName() ) )
{
try
{
m_pi->SaveLibrary( fn.GetFullPath() );
@ -833,6 +850,10 @@ bool SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary( wxWindow *aParent )
return false;
}
// If the rescue library already exists in the symbol library table no need save it to add
// it to the table.
if( !m_prj->SchSymbolLibTable()->HasLibrary( fn.GetName() ) )
{
wxString uri = wxT( "${KIPRJMOD}/" ) + fn.GetFullName();
wxString libNickname = fn.GetName();
@ -880,10 +901,7 @@ void SYMBOL_LIB_TABLE_RESCUER::AddSymbol( LIB_SYMBOL* aNewSymbol )
try
{
if( !m_prj->SchSymbolLibTable()->HasLibrary( fn.GetName() ) )
m_pi->SaveSymbol( fn.GetFullPath(), new LIB_SYMBOL( *aNewSymbol ), m_properties.get() );
else
m_prj->SchSymbolLibTable()->SaveSymbol( fn.GetName(), new LIB_SYMBOL( *aNewSymbol ) );
}
catch( ... /* IO_ERROR */ )
{