Fix crash when .kicad_pcb is renamed to .kicad_mod and load library attempted
Pick a random error message used elsewhere
This commit is contained in:
parent
d04cda35c5
commit
d4a5e2caad
|
@ -184,8 +184,15 @@ void FP_CACHE::Load()
|
||||||
FILE_LINE_READER reader( fn.GetFullPath() );
|
FILE_LINE_READER reader( fn.GetFullPath() );
|
||||||
PCB_PARSER parser( &reader, nullptr, nullptr );
|
PCB_PARSER parser( &reader, nullptr, nullptr );
|
||||||
|
|
||||||
FOOTPRINT* footprint = (FOOTPRINT*) parser.Parse();
|
// use dynamic cast in case somebody renames a .kicad_pcb as .kicad_mod and chucks it into a library folder
|
||||||
wxString fpName = fn.GetName();
|
// the parsing definitely fails then
|
||||||
|
FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( parser.Parse() );
|
||||||
|
wxString fpName = fn.GetName();
|
||||||
|
|
||||||
|
if( !footprint )
|
||||||
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'" ), fn.GetFullPath() ) );
|
||||||
|
}
|
||||||
|
|
||||||
footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) );
|
footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) );
|
||||||
m_footprints.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) );
|
m_footprints.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) );
|
||||||
|
|
Loading…
Reference in New Issue