From e05c8f88523eaab68dbbf647dcc9a4b6c3865287 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 6 May 2022 16:12:25 -0700 Subject: [PATCH] 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 --- .../symbol_editor/symbol_library_manager.cpp | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/eeschema/symbol_editor/symbol_library_manager.cpp b/eeschema/symbol_editor/symbol_library_manager.cpp index 2f615529cc..00791ec327 100644 --- a/eeschema/symbol_editor/symbol_library_manager.cpp +++ b/eeschema/symbol_editor/symbol_library_manager.cpp @@ -959,11 +959,23 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptrGetName() != originalSymbol->GetName() ) { - if( aLibTable->LoadSymbol( m_libName, originalSymbol->GetName() ) ) - aLibTable->DeleteSymbol( m_libName, originalSymbol->GetName() ); + // DeleteSymbol may throw + 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() ) @@ -1054,8 +1066,17 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptrGetName() != originalSymbol->GetName() ) { - if( aPlugin->LoadSymbol( aFileName, originalSymbol->GetName() ) ) - aPlugin->DeleteSymbol( aFileName, originalSymbol->GetName(), &properties ); + try + { + 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() )