Pcbnew: continue loading footprints after first failure.
The footprint library cache handler would throw an exception on the first error it encountered preventing all subsequent footprint files from being parsed even if there was nothing wrong with them. This commit queues errors until all of the footprint files in the folder have been parsed. Fixes lp:1416736 https://bugs.launchpad.net/kicad/+bug/1416736
This commit is contained in:
parent
342f28f106
commit
096d9fbbf9
|
@ -95,7 +95,11 @@ void FOOTPRINT_LIST::DisplayErrors( wxTopLevelWindow* aWindow )
|
|||
|
||||
while( auto error = PopError() )
|
||||
{
|
||||
msg += wxT( "<p>" ) + error->Problem() + wxT( "</p>" );
|
||||
wxString tmp = error->Problem();
|
||||
|
||||
// Preserve new lines in error messages so queued errors don't run together.
|
||||
tmp.Replace( "\n", "<BR>" );
|
||||
msg += wxT( "<p>" ) + tmp + wxT( "</p>" );
|
||||
}
|
||||
|
||||
dlg.AddHTML_Text( msg );
|
||||
|
|
|
@ -287,28 +287,43 @@ void FP_CACHE::Load()
|
|||
|
||||
if( dir.GetFirst( &fpFileName, wildcard, wxDIR_FILES ) )
|
||||
{
|
||||
wxString cacheError;
|
||||
|
||||
do
|
||||
{
|
||||
// prepend the libpath into fullPath
|
||||
wxFileName fullPath( m_lib_path.GetPath(), fpFileName );
|
||||
|
||||
FILE_LINE_READER reader( fullPath.GetFullPath() );
|
||||
// Queue I/O errors so only files that fail to parse don't get loaded.
|
||||
try
|
||||
{
|
||||
FILE_LINE_READER reader( fullPath.GetFullPath() );
|
||||
|
||||
m_owner->m_parser->SetLineReader( &reader );
|
||||
m_owner->m_parser->SetLineReader( &reader );
|
||||
|
||||
std::string name = TO_UTF8( fullPath.GetName() );
|
||||
MODULE* footprint = (MODULE*) m_owner->m_parser->Parse();
|
||||
std::string name = TO_UTF8( fullPath.GetName() );
|
||||
MODULE* footprint = (MODULE*) m_owner->m_parser->Parse();
|
||||
|
||||
// The footprint name is the file name without the extension.
|
||||
footprint->SetFPID( LIB_ID( fullPath.GetName() ) );
|
||||
m_modules.insert( name, new FP_CACHE_ITEM( footprint, fullPath ) );
|
||||
// The footprint name is the file name without the extension.
|
||||
footprint->SetFPID( LIB_ID( fullPath.GetName() ) );
|
||||
m_modules.insert( name, new FP_CACHE_ITEM( footprint, fullPath ) );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
if( !cacheError.IsEmpty() )
|
||||
cacheError += "\n\n";
|
||||
|
||||
cacheError += ioe.What();
|
||||
}
|
||||
} while( dir.GetNext( &fpFileName ) );
|
||||
|
||||
// Remember the file modification time of library file when the
|
||||
// cache snapshot was made, so that in a networked environment we will
|
||||
// reload the cache as needed.
|
||||
m_mod_time = GetLibModificationTime();
|
||||
|
||||
if( !cacheError.IsEmpty() )
|
||||
THROW_IO_ERROR( cacheError );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue