Fix possible crash and issues when a incorrect fp lib table is loaded:

correct lines are loaded, and pcbnew is no longer aborted.
This commit is contained in:
jean-pierre charras 2017-07-12 20:27:18 +02:00
parent c0fab4b350
commit 464175e995
3 changed files with 14 additions and 8 deletions

View File

@ -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 );
}

View File

@ -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" ),

View File

@ -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)