Run some sanity checks on fp-info-cache files.
Fixes: lp:1803989 * https://bugs.launchpad.net/kicad/+bug/1803989
This commit is contained in:
parent
984d3f04ab
commit
c016861962
|
@ -371,14 +371,14 @@ void FOOTPRINT_LIST_IMPL::WriteCacheToFile( wxTextFile* aCacheFile )
|
|||
|
||||
void FOOTPRINT_LIST_IMPL::ReadCacheFromFile( wxTextFile* aCacheFile )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_list_timestamp = 0;
|
||||
m_list.clear();
|
||||
|
||||
try
|
||||
{
|
||||
if( aCacheFile->Exists() )
|
||||
{
|
||||
aCacheFile->Open();
|
||||
else
|
||||
return;
|
||||
|
||||
aCacheFile->GetFirstLine().ToLongLong( &m_list_timestamp );
|
||||
|
||||
|
@ -397,12 +397,17 @@ void FOOTPRINT_LIST_IMPL::ReadCacheFromFile( wxTextFile* aCacheFile )
|
|||
m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// whatever went wrong, invalidate the cache
|
||||
m_list_timestamp = 0;
|
||||
}
|
||||
|
||||
// Sanity check: an empty list is very unlikely to be correct.
|
||||
if( m_list.size() == 0 )
|
||||
m_list_timestamp = 0;
|
||||
|
||||
if( aCacheFile->IsOpened() )
|
||||
aCacheFile->Close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue