From 1874ad2f7e5625b07c2d18cdf42d650ba3cbd857 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 3 Jan 2022 15:29:01 -0800 Subject: [PATCH] Catch errors from `load()` Loading footprints may throw in some cases. We need to catch these nicely without breaking out of the full loading process Fixes https://gitlab.com/kicad/code/kicad/issues/10213 --- pcbnew/footprint_info_impl.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/pcbnew/footprint_info_impl.cpp b/pcbnew/footprint_info_impl.cpp index 1cbaa96b74..718d481925 100644 --- a/pcbnew/footprint_info_impl.cpp +++ b/pcbnew/footprint_info_impl.cpp @@ -288,9 +288,29 @@ bool FOOTPRINT_LIST_IMPL::joinWorkers() for( unsigned jj = 0; jj < fpnames.size() && !m_cancelled; ++jj ) { - wxString fpname = fpnames[jj]; - FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO_IMPL( this, nickname, fpname ); - queue_parsed.move_push( std::unique_ptr( fpinfo ) ); + try + { + wxString fpname = fpnames[jj]; + FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO_IMPL( this, nickname, fpname ); + queue_parsed.move_push( std::unique_ptr( fpinfo ) ); + } + catch( const IO_ERROR& ioe ) + { + m_errors.move_push( std::make_unique( ioe ) ); + } + catch( const std::exception& se ) + { + // This is a round about way to do this, but who knows what THROW_IO_ERROR() + // may be tricked out to do someday, keep it in the game. + try + { + THROW_IO_ERROR( se.what() ); + } + catch( const IO_ERROR& ioe ) + { + m_errors.move_push( std::make_unique( ioe ) ); + } + } } if( m_progress_reporter )