pcbnew: Check before reading/writing cache

The open/create calls can fail so we need to account for this before
using the result that assumes success.
This commit is contained in:
Seth Hillbrand 2020-01-17 17:53:43 -08:00
parent 8341398082
commit 73d6169338
1 changed files with 6 additions and 5 deletions

View File

@ -342,12 +342,15 @@ void FOOTPRINT_LIST_IMPL::WriteCacheToFile( wxTextFile* aCacheFile )
{
if( aCacheFile->Exists() )
{
aCacheFile->Open();
if( !aCacheFile->Open() )
return;
aCacheFile->Clear();
}
else
{
aCacheFile->Create();
if( !aCacheFile->Create() )
return;
}
aCacheFile->AddLine( wxString::Format( "%lld", m_list_timestamp ) );
@ -375,10 +378,8 @@ void FOOTPRINT_LIST_IMPL::ReadCacheFromFile( wxTextFile* aCacheFile )
try
{
if( aCacheFile->Exists() )
if( aCacheFile->Exists() && aCacheFile->Open() )
{
aCacheFile->Open();
aCacheFile->GetFirstLine().ToLongLong( &m_list_timestamp );
while( aCacheFile->GetCurrentLine() + 6 < aCacheFile->GetLineCount() )