From 464175e9958ae1766a6b90ebb629f2aa75fc0296 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 12 Jul 2017 20:27:18 +0200 Subject: [PATCH] Fix possible crash and issues when a incorrect fp lib table is loaded: correct lines are loaded, and pcbnew is no longer aborted. --- common/fp_lib_table.cpp | 13 ++++++++----- cvpcb/menubar.cpp | 2 +- pcbnew/pcbnew.cpp | 7 +++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index ca3de578f4..d9fc1e729a 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -260,6 +260,7 @@ void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR */ T tok; + wxString errMsg; // to collect error messages // This table may be nested within a larger s-expression, or not. // Allow for parser of that optional containing s-epression to have looked ahead. @@ -280,10 +281,6 @@ void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR if( tok != T_LEFT ) in->Expecting( T_LEFT ); - // in case there is a "row integrity" error, tell where later. - int lineNum = in->CurLineNumber(); - int offset = in->CurOffset(); - if( ( tok = in->NextTok() ) != T_lib ) in->Expecting( T_lib ); @@ -382,9 +379,15 @@ void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR wxString msg = wxString::Format( _( "'%s' is a duplicate footprint library nickName" ), GetChars( row.nickName ) ); - THROW_PARSE_ERROR( msg, in->CurSource(), in->CurLine(), lineNum, offset ); + if( !errMsg.IsEmpty() ) + errMsg << '\n'; + + errMsg << msg; } } + + if( !errMsg.IsEmpty() ) + THROW_IO_ERROR( errMsg ); } diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index 612c593eb7..9be8744866 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -91,7 +91,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() KiBitmap( editor_xpm ) ); AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT, - _( "&Footprint &Association Files" ), + _( "Footprint &Association Files" ), _( "Configure footprint association file (.equ) list." "These files are used to automatically assign" "the footprint name from the component value" ), diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index ddbdd03d81..c6421edf0a 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -345,13 +345,16 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) } catch( const IO_ERROR& ioe ) { + // if we are here, a incorrect global footprint library table was found. + // Incorrect global footprint library table is not a fatal error: + // the user just has to edit the (partially) loaded table. wxString msg = wxString::Format( _( "An error occurred attempting to load the global footprint library " - "table:\n\n%s" ), + "table:\n\n%s\n\n" + "Please edit this global footprint library table in Preferences menu" ), GetChars( ioe.errorText ) ); DisplayError( NULL, msg ); - return false; } #if defined(KICAD_SCRIPTING)