2017-03-23 00:59:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
|
|
|
|
* Copyright (C) 2013-2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2022-11-10 11:50:00 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-03-23 00:59:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <footprint_info_impl.h>
|
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2017-03-23 00:59:25 +00:00
|
|
|
#include <footprint_info.h>
|
|
|
|
#include <fp_lib_table.h>
|
|
|
|
#include <kiway.h>
|
2022-06-15 00:41:10 +00:00
|
|
|
#include <locale_io.h>
|
2017-03-23 00:59:25 +00:00
|
|
|
#include <lib_id.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <progress_reporter.h>
|
2022-06-15 00:41:10 +00:00
|
|
|
#include <string_utils.h>
|
2023-09-06 21:19:38 +00:00
|
|
|
#include <core/thread_pool.h>
|
2022-06-15 00:41:10 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
|
2023-05-25 00:07:46 +00:00
|
|
|
#include <kiplatform/io.h>
|
|
|
|
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <wx/textfile.h>
|
2020-12-11 01:08:51 +00:00
|
|
|
#include <wx/txtstrm.h>
|
|
|
|
#include <wx/wfstream.h>
|
2017-03-23 00:59:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_INFO_IMPL::load()
|
|
|
|
{
|
|
|
|
FP_LIB_TABLE* fptable = m_owner->GetTable();
|
|
|
|
|
|
|
|
wxASSERT( fptable );
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
const FOOTPRINT* footprint = fptable->GetEnumeratedFootprint( m_nickname, m_fpname );
|
2018-07-30 13:18:37 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( footprint == nullptr ) // Should happen only with malformed/broken libraries
|
2017-03-23 00:59:25 +00:00
|
|
|
{
|
|
|
|
m_pad_count = 0;
|
|
|
|
m_unique_pad_count = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pad_count = footprint->GetPadCount( DO_NOT_INCLUDE_NPTH );
|
|
|
|
m_unique_pad_count = footprint->GetUniquePadCount( DO_NOT_INCLUDE_NPTH );
|
|
|
|
m_keywords = footprint->GetKeywords();
|
2023-06-19 17:08:18 +00:00
|
|
|
m_doc = footprint->GetLibDescription();
|
2017-03-23 00:59:25 +00:00
|
|
|
}
|
2018-07-30 13:18:37 +00:00
|
|
|
|
|
|
|
m_loaded = true;
|
2017-03-23 00:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
bool FOOTPRINT_LIST_IMPL::CatchErrors( const std::function<void()>& aFunc )
|
2017-03-23 00:59:25 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aFunc();
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch( const std::exception& se )
|
|
|
|
{
|
|
|
|
// This is a round about way to do this, but who knows what THROW_IO_ERROR()
|
|
|
|
// may be tricked out to do someday, keep it in the game.
|
|
|
|
try
|
|
|
|
{
|
|
|
|
THROW_IO_ERROR( se.what() );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname,
|
2018-04-16 22:18:02 +00:00
|
|
|
PROGRESS_REPORTER* aProgressReporter )
|
2017-03-23 00:59:25 +00:00
|
|
|
{
|
2022-11-29 22:07:33 +00:00
|
|
|
long long int generatedTimestamp = 0;
|
|
|
|
|
|
|
|
if( !CatchErrors( [&]()
|
|
|
|
{
|
|
|
|
generatedTimestamp = aTable->GenerateTimestamp( aNickname );
|
|
|
|
} ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-30 13:18:37 +00:00
|
|
|
|
|
|
|
if( generatedTimestamp == m_list_timestamp )
|
2018-02-05 20:55:00 +00:00
|
|
|
return true;
|
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
// Disable KIID generation: not needed for library parts; sometimes very slow
|
|
|
|
KIID_NIL_SET_RESET reset_kiid;
|
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
m_progress_reporter = aProgressReporter;
|
2020-08-09 10:55:00 +00:00
|
|
|
|
|
|
|
if( m_progress_reporter )
|
|
|
|
{
|
|
|
|
m_progress_reporter->SetMaxProgress( m_queue_in.size() );
|
2021-06-26 11:33:37 +00:00
|
|
|
m_progress_reporter->Report( _( "Fetching footprint libraries..." ) );
|
2020-08-09 10:55:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
m_cancelled = false;
|
2022-06-15 00:41:10 +00:00
|
|
|
m_lib_table = aTable;
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
// Clear data before reading files
|
|
|
|
m_errors.clear();
|
|
|
|
m_list.clear();
|
|
|
|
m_queue_in.clear();
|
|
|
|
m_queue_out.clear();
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
if( aNickname )
|
2018-02-10 13:32:57 +00:00
|
|
|
{
|
2022-06-15 00:41:10 +00:00
|
|
|
m_queue_in.push( *aNickname );
|
2018-02-10 13:32:57 +00:00
|
|
|
}
|
2022-06-15 00:41:10 +00:00
|
|
|
else
|
2018-05-23 15:52:48 +00:00
|
|
|
{
|
2022-11-10 11:50:00 +00:00
|
|
|
for( const wxString& nickname : aTable->GetLogicalLibs() )
|
2022-06-15 00:41:10 +00:00
|
|
|
m_queue_in.push( nickname );
|
2018-05-23 15:52:48 +00:00
|
|
|
}
|
2022-06-15 00:41:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
loadLibs();
|
|
|
|
|
|
|
|
if( !m_cancelled )
|
2018-02-10 13:32:57 +00:00
|
|
|
{
|
|
|
|
if( m_progress_reporter )
|
|
|
|
{
|
|
|
|
m_progress_reporter->SetMaxProgress( m_queue_out.size() );
|
2020-08-09 10:55:00 +00:00
|
|
|
m_progress_reporter->AdvancePhase();
|
2021-06-26 11:33:37 +00:00
|
|
|
m_progress_reporter->Report( _( "Loading footprints..." ) );
|
2018-02-10 13:32:57 +00:00
|
|
|
}
|
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
loadFootprints();
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2018-05-23 15:52:48 +00:00
|
|
|
if( m_progress_reporter )
|
|
|
|
m_progress_reporter->AdvancePhase();
|
2018-02-10 13:32:57 +00:00
|
|
|
}
|
2018-02-05 20:55:00 +00:00
|
|
|
|
2018-07-30 13:18:37 +00:00
|
|
|
if( m_cancelled )
|
2021-07-19 23:56:05 +00:00
|
|
|
m_list_timestamp = 0; // God knows what we got before we were canceled
|
2018-07-30 13:18:37 +00:00
|
|
|
else
|
|
|
|
m_list_timestamp = generatedTimestamp;
|
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
return m_errors.empty();
|
2017-03-23 00:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
void FOOTPRINT_LIST_IMPL::loadLibs()
|
2017-03-23 00:59:25 +00:00
|
|
|
{
|
2022-06-15 00:41:10 +00:00
|
|
|
thread_pool& tp = GetKiCadThreadPool();
|
|
|
|
size_t num_returns = m_queue_in.size();
|
|
|
|
std::vector<std::future<size_t>> returns( num_returns );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
auto loader_job =
|
|
|
|
[this]() -> size_t
|
2022-06-15 00:41:10 +00:00
|
|
|
{
|
2022-11-10 11:50:00 +00:00
|
|
|
wxString nickname;
|
|
|
|
size_t retval = 0;
|
|
|
|
|
|
|
|
if( !m_cancelled && m_queue_in.pop( nickname ) )
|
2022-06-15 00:41:10 +00:00
|
|
|
{
|
2022-11-10 11:50:00 +00:00
|
|
|
if( CatchErrors( [this, &nickname]()
|
|
|
|
{
|
|
|
|
m_lib_table->PrefetchLib( nickname );
|
|
|
|
m_queue_out.push( nickname );
|
|
|
|
} ) && m_progress_reporter )
|
|
|
|
{
|
|
|
|
m_progress_reporter->AdvanceProgress();
|
|
|
|
}
|
2018-05-23 15:52:48 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
++retval;
|
|
|
|
}
|
2018-06-04 20:44:43 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
return retval;
|
|
|
|
};
|
2018-05-23 15:52:48 +00:00
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
for( size_t ii = 0; ii < num_returns; ++ii )
|
|
|
|
returns[ii] = tp.submit( loader_job );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-09-14 20:28:46 +00:00
|
|
|
for( const std::future<size_t>& ret : returns )
|
2018-06-04 20:44:43 +00:00
|
|
|
{
|
2022-09-14 20:28:46 +00:00
|
|
|
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2022-09-14 20:28:46 +00:00
|
|
|
while( status != std::future_status::ready )
|
2022-06-15 00:41:10 +00:00
|
|
|
{
|
|
|
|
if( m_progress_reporter && !m_progress_reporter->KeepRefreshing() )
|
|
|
|
m_cancelled = true;
|
2018-06-04 20:44:43 +00:00
|
|
|
|
2022-09-14 20:28:46 +00:00
|
|
|
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
2022-08-03 09:10:23 +00:00
|
|
|
}
|
2018-06-04 20:44:43 +00:00
|
|
|
}
|
2022-06-15 00:41:10 +00:00
|
|
|
}
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
void FOOTPRINT_LIST_IMPL::loadFootprints()
|
|
|
|
{
|
2017-03-23 00:59:25 +00:00
|
|
|
LOCALE_IO toggle_locale;
|
|
|
|
|
|
|
|
// Parse the footprints in parallel. WARNING! This requires changing the locale, which is
|
2021-07-19 23:56:05 +00:00
|
|
|
// GLOBAL. It is only thread safe to construct the LOCALE_IO before the threads are created,
|
2017-03-23 00:59:25 +00:00
|
|
|
// destroy it after they finish, and block the main (GUI) thread while they work. Any deviation
|
|
|
|
// from this will cause nasal demons.
|
|
|
|
//
|
|
|
|
// TODO: blast LOCALE_IO into the sun
|
|
|
|
|
|
|
|
SYNC_QUEUE<std::unique_ptr<FOOTPRINT_INFO>> queue_parsed;
|
2022-11-10 11:50:00 +00:00
|
|
|
thread_pool& tp = GetKiCadThreadPool();
|
|
|
|
size_t num_elements = m_queue_out.size();
|
|
|
|
std::vector<std::future<size_t>> returns( num_elements );
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
auto fp_thread =
|
|
|
|
[ this, &queue_parsed ]() -> size_t
|
|
|
|
{
|
|
|
|
wxString nickname;
|
2017-03-24 14:09:08 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
if( m_cancelled || !m_queue_out.pop( nickname ) )
|
|
|
|
return 0;
|
2017-06-11 20:20:44 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
wxArrayString fpnames;
|
2017-06-11 20:20:44 +00:00
|
|
|
|
2022-11-10 13:46:50 +00:00
|
|
|
CatchErrors(
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
m_lib_table->FootprintEnumerate( fpnames, nickname, false );
|
|
|
|
} );
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
for( wxString fpname : fpnames )
|
|
|
|
{
|
|
|
|
CatchErrors(
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
auto* fpinfo = new FOOTPRINT_INFO_IMPL( this, nickname, fpname );
|
|
|
|
queue_parsed.move_push( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
|
2022-11-10 13:46:50 +00:00
|
|
|
} );
|
2022-11-10 11:50:00 +00:00
|
|
|
|
|
|
|
if( m_cancelled )
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
if( m_progress_reporter )
|
|
|
|
m_progress_reporter->AdvanceProgress();
|
2022-06-15 00:41:10 +00:00
|
|
|
|
2022-11-10 11:50:00 +00:00
|
|
|
return 1;
|
|
|
|
};
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
for( size_t ii = 0; ii < num_elements; ++ii )
|
|
|
|
returns[ii] = tp.submit( fp_thread );
|
|
|
|
|
2022-09-14 20:28:46 +00:00
|
|
|
for( const std::future<size_t>& ret : returns )
|
2018-02-10 13:32:57 +00:00
|
|
|
{
|
2022-09-14 20:28:46 +00:00
|
|
|
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
2018-06-04 20:44:43 +00:00
|
|
|
|
2022-09-14 20:28:46 +00:00
|
|
|
while( status != std::future_status::ready )
|
2022-06-15 00:41:10 +00:00
|
|
|
{
|
|
|
|
if( m_progress_reporter )
|
|
|
|
m_progress_reporter->KeepRefreshing();
|
2018-02-10 13:32:57 +00:00
|
|
|
|
2022-09-14 20:28:46 +00:00
|
|
|
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
2022-08-03 09:10:23 +00:00
|
|
|
}
|
2022-06-15 00:41:10 +00:00
|
|
|
}
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2017-03-24 14:09:08 +00:00
|
|
|
std::unique_ptr<FOOTPRINT_INFO> fpi;
|
|
|
|
|
|
|
|
while( queue_parsed.pop( fpi ) )
|
|
|
|
m_list.push_back( std::move( fpi ) );
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
std::sort( m_list.begin(), m_list.end(),
|
|
|
|
[]( std::unique_ptr<FOOTPRINT_INFO> const& lhs,
|
|
|
|
std::unique_ptr<FOOTPRINT_INFO> const& rhs ) -> bool
|
|
|
|
{
|
|
|
|
return *lhs < *rhs;
|
|
|
|
} );
|
2017-03-23 00:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
FOOTPRINT_LIST_IMPL::FOOTPRINT_LIST_IMPL() :
|
2018-02-23 12:21:06 +00:00
|
|
|
m_list_timestamp( 0 ),
|
2018-02-20 08:14:51 +00:00
|
|
|
m_progress_reporter( nullptr ),
|
|
|
|
m_cancelled( false )
|
2017-03-23 00:59:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
void FOOTPRINT_LIST_IMPL::WriteCacheToFile( const wxString& aFilePath )
|
2018-08-03 16:53:38 +00:00
|
|
|
{
|
2020-12-11 04:07:49 +00:00
|
|
|
wxFileName tmpFileName = wxFileName::CreateTempFileName( aFilePath );
|
|
|
|
wxFFileOutputStream outStream( tmpFileName.GetFullPath() );
|
|
|
|
wxTextOutputStream txtStream( outStream );
|
2020-01-18 01:53:43 +00:00
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
if( !outStream.IsOk() )
|
2018-08-03 16:53:38 +00:00
|
|
|
{
|
2020-12-11 01:08:51 +00:00
|
|
|
return;
|
2018-08-03 16:53:38 +00:00
|
|
|
}
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
txtStream << wxString::Format( wxT( "%lld" ), m_list_timestamp ) << endl;
|
2018-08-03 16:53:38 +00:00
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
for( std::unique_ptr<FOOTPRINT_INFO>& fpinfo : m_list )
|
2018-08-03 16:53:38 +00:00
|
|
|
{
|
2020-12-11 01:08:51 +00:00
|
|
|
txtStream << fpinfo->GetLibNickname() << endl;
|
|
|
|
txtStream << fpinfo->GetName() << endl;
|
|
|
|
txtStream << EscapeString( fpinfo->GetDescription(), CTX_LINE ) << endl;
|
|
|
|
txtStream << EscapeString( fpinfo->GetKeywords(), CTX_LINE ) << endl;
|
2022-02-04 22:44:59 +00:00
|
|
|
txtStream << wxString::Format( wxT( "%d" ), fpinfo->GetOrderNum() ) << endl;
|
|
|
|
txtStream << wxString::Format( wxT( "%u" ), fpinfo->GetPadCount() ) << endl;
|
|
|
|
txtStream << wxString::Format( wxT( "%u" ), fpinfo->GetUniquePadCount() ) << endl;
|
2018-08-03 16:53:38 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
txtStream.Flush();
|
2020-12-11 04:07:49 +00:00
|
|
|
outStream.Close();
|
|
|
|
|
2023-05-25 00:07:46 +00:00
|
|
|
// Preserve the permissions of the current file
|
|
|
|
KIPLATFORM::IO::DuplicatePermissions( aFilePath, tmpFileName.GetFullPath() );
|
|
|
|
|
2020-12-11 04:07:49 +00:00
|
|
|
if( !wxRenameFile( tmpFileName.GetFullPath(), aFilePath, true ) )
|
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
// cleanup in case rename failed
|
2020-12-11 04:07:49 +00:00
|
|
|
// its also not the end of the world since this is just a cache file
|
|
|
|
wxRemoveFile( tmpFileName.GetFullPath() );
|
|
|
|
}
|
2018-08-03 16:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
void FOOTPRINT_LIST_IMPL::ReadCacheFromFile( const wxString& aFilePath )
|
2018-08-03 16:53:38 +00:00
|
|
|
{
|
2020-12-11 01:08:51 +00:00
|
|
|
wxTextFile cacheFile( aFilePath );
|
|
|
|
|
2018-11-19 21:06:02 +00:00
|
|
|
m_list_timestamp = 0;
|
|
|
|
m_list.clear();
|
|
|
|
|
2018-08-03 16:53:38 +00:00
|
|
|
try
|
|
|
|
{
|
2020-12-11 01:08:51 +00:00
|
|
|
if( cacheFile.Exists() && cacheFile.Open() )
|
2018-11-19 21:06:02 +00:00
|
|
|
{
|
2020-12-11 01:08:51 +00:00
|
|
|
cacheFile.GetFirstLine().ToLongLong( &m_list_timestamp );
|
2018-08-03 16:53:38 +00:00
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
|
2018-11-19 21:06:02 +00:00
|
|
|
{
|
2021-05-14 21:23:40 +00:00
|
|
|
wxString libNickname = cacheFile.GetNextLine();
|
|
|
|
wxString name = cacheFile.GetNextLine();
|
|
|
|
wxString desc = UnescapeString( cacheFile.GetNextLine() );
|
|
|
|
wxString keywords = UnescapeString( cacheFile.GetNextLine() );
|
|
|
|
int orderNum = wxAtoi( cacheFile.GetNextLine() );
|
|
|
|
unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
|
|
|
|
unsigned int uniquePadCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
|
|
|
|
|
|
|
|
FOOTPRINT_INFO_IMPL* fpinfo = new FOOTPRINT_INFO_IMPL( libNickname, name, desc,
|
|
|
|
keywords, orderNum,
|
|
|
|
padCount, uniquePadCount );
|
|
|
|
|
2018-11-19 21:06:02 +00:00
|
|
|
m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
|
|
|
|
}
|
2018-08-03 16:53:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
// whatever went wrong, invalidate the cache
|
|
|
|
m_list_timestamp = 0;
|
|
|
|
}
|
|
|
|
|
2018-11-19 21:06:02 +00:00
|
|
|
// Sanity check: an empty list is very unlikely to be correct.
|
|
|
|
if( m_list.size() == 0 )
|
|
|
|
m_list_timestamp = 0;
|
|
|
|
|
2020-12-11 01:08:51 +00:00
|
|
|
if( cacheFile.IsOpened() )
|
|
|
|
cacheFile.Close();
|
2018-08-03 16:53:38 +00:00
|
|
|
}
|