Catch throws in DeleteSymbol
DeleteSymbol may call SaveSymbol if the name is changed. In this case, SaveSymbol may throw back and needs to be caught Fixes https://gitlab.com/kicad/code/kicad/issues/11566
This commit is contained in:
parent
485e89f7a5
commit
e05c8f8852
|
@ -959,11 +959,23 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr<SYMBOL_BUFF
|
||||||
PROPERTIES properties;
|
PROPERTIES properties;
|
||||||
properties.emplace( SCH_LEGACY_PLUGIN::PropBuffering, wxEmptyString );
|
properties.emplace( SCH_LEGACY_PLUGIN::PropBuffering, wxEmptyString );
|
||||||
|
|
||||||
|
wxString errorMsg = _( "Error saving symbol %s to library '%s'." ) + wxS( "\n%s" );
|
||||||
|
|
||||||
// Delete the original symbol if the symbol name has been changed.
|
// Delete the original symbol if the symbol name has been changed.
|
||||||
if( libSymbol->GetName() != originalSymbol->GetName() )
|
if( libSymbol->GetName() != originalSymbol->GetName() )
|
||||||
{
|
{
|
||||||
if( aLibTable->LoadSymbol( m_libName, originalSymbol->GetName() ) )
|
// DeleteSymbol may throw
|
||||||
aLibTable->DeleteSymbol( m_libName, originalSymbol->GetName() );
|
try
|
||||||
|
{
|
||||||
|
if( aLibTable->LoadSymbol( m_libName, originalSymbol->GetName() ) )
|
||||||
|
aLibTable->DeleteSymbol( m_libName, originalSymbol->GetName() );
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& ioe )
|
||||||
|
{
|
||||||
|
wxLogError( errorMsg, UnescapeString( originalSymbol->GetName() ), m_libName,
|
||||||
|
ioe.What() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( libSymbol->IsAlias() )
|
if( libSymbol->IsAlias() )
|
||||||
|
@ -1054,8 +1066,17 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr<SYMBOL_BUFF
|
||||||
// Delete the original symbol if the symbol name has been changed.
|
// Delete the original symbol if the symbol name has been changed.
|
||||||
if( libSymbol->GetName() != originalSymbol->GetName() )
|
if( libSymbol->GetName() != originalSymbol->GetName() )
|
||||||
{
|
{
|
||||||
if( aPlugin->LoadSymbol( aFileName, originalSymbol->GetName() ) )
|
try
|
||||||
aPlugin->DeleteSymbol( aFileName, originalSymbol->GetName(), &properties );
|
{
|
||||||
|
if( aPlugin->LoadSymbol( aFileName, originalSymbol->GetName() ) )
|
||||||
|
aPlugin->DeleteSymbol( aFileName, originalSymbol->GetName(), &properties );
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& ioe )
|
||||||
|
{
|
||||||
|
wxLogError( errorMsg, UnescapeString( originalSymbol->GetName() ), aFileName,
|
||||||
|
ioe.What() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( libSymbol->IsAlias() )
|
if( libSymbol->IsAlias() )
|
||||||
|
|
Loading…
Reference in New Issue