Load footprint info when there's no cache available.
Fixes https://gitlab.com/kicad/code/kicad/issues/8371
This commit is contained in:
parent
ebd53cd45c
commit
ccaf9e11df
|
@ -140,13 +140,11 @@ FOOTPRINT_LIST* FOOTPRINT_LIST::GetInstance( KIWAY& aKiway )
|
||||||
{
|
{
|
||||||
FOOTPRINT_LIST* footprintInfo = get_instance_from_id( aKiway, KIFACE_FOOTPRINT_LIST );
|
FOOTPRINT_LIST* footprintInfo = get_instance_from_id( aKiway, KIFACE_FOOTPRINT_LIST );
|
||||||
|
|
||||||
if( ! footprintInfo )
|
if( !footprintInfo )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if( !footprintInfo->GetCount() )
|
if( !footprintInfo->GetCount() )
|
||||||
{
|
|
||||||
footprintInfo->ReadCacheFromFile( aKiway.Prj().GetProjectPath() + "fp-info-cache" );
|
footprintInfo->ReadCacheFromFile( aKiway.Prj().GetProjectPath() + "fp-info-cache" );
|
||||||
}
|
|
||||||
|
|
||||||
return footprintInfo;
|
return footprintInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,15 @@
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <widgets/footprint_choice.h>
|
#include <widgets/footprint_choice.h>
|
||||||
#include <widgets/footprint_select_widget.h>
|
#include <widgets/footprint_select_widget.h>
|
||||||
|
|
||||||
#include <wx/wupdlock.h>
|
|
||||||
#include <widgets/progress_reporter.h>
|
#include <widgets/progress_reporter.h>
|
||||||
|
#include <footprint_info_impl.h>
|
||||||
|
#include <wx/wupdlock.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern FOOTPRINT_LIST_IMPL GFootprintList; // KIFACE scope.
|
||||||
|
|
||||||
wxDEFINE_EVENT( EVT_FOOTPRINT_SELECTED, wxCommandEvent );
|
wxDEFINE_EVENT( EVT_FOOTPRINT_SELECTED, wxCommandEvent );
|
||||||
|
|
||||||
|
|
||||||
FOOTPRINT_SELECT_WIDGET::FOOTPRINT_SELECT_WIDGET( EDA_DRAW_FRAME* aFrame, wxWindow* aParent,
|
FOOTPRINT_SELECT_WIDGET::FOOTPRINT_SELECT_WIDGET( EDA_DRAW_FRAME* aFrame, wxWindow* aParent,
|
||||||
FOOTPRINT_LIST* aFpList, bool aUpdate,
|
FOOTPRINT_LIST* aFpList, bool aUpdate,
|
||||||
int aMaxItems ) :
|
int aMaxItems ) :
|
||||||
|
@ -60,6 +61,15 @@ void FOOTPRINT_SELECT_WIDGET::Load( KIWAY& aKiway, PROJECT& aProject )
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
|
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
|
||||||
|
|
||||||
|
if( m_fp_list->GetCount() == 0 )
|
||||||
|
{
|
||||||
|
// If the fp-info-cache is empty (or, more likely, hasn't been created in a new
|
||||||
|
// project yet), load footprints the hard way.
|
||||||
|
FP_LIB_TABLE* fpTable = aProject.PcbFootprintLibs( aKiway );
|
||||||
|
static_cast<FOOTPRINT_LIST_IMPL*>( m_fp_list )->ReadFootprintFiles( fpTable );
|
||||||
|
}
|
||||||
|
|
||||||
m_fp_filter.SetList( *m_fp_list );
|
m_fp_filter.SetList( *m_fp_list );
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
|
@ -137,7 +147,7 @@ bool FOOTPRINT_SELECT_WIDGET::UpdateList()
|
||||||
|
|
||||||
if( !m_zero_filter )
|
if( !m_zero_filter )
|
||||||
{
|
{
|
||||||
for( auto& fpinfo : m_fp_filter )
|
for( FOOTPRINT_INFO& fpinfo : m_fp_filter )
|
||||||
{
|
{
|
||||||
wxString display_name( fpinfo.GetLibNickname() + ":" + fpinfo.GetFootprintName() );
|
wxString display_name( fpinfo.GetLibNickname() + ":" + fpinfo.GetFootprintName() );
|
||||||
|
|
||||||
|
|
|
@ -811,10 +811,10 @@ void FOOTPRINT_EDIT_FRAME::initLibraryTree()
|
||||||
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
||||||
|
|
||||||
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
|
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
|
||||||
|
|
||||||
if( GFootprintList.GetCount() == 0 )
|
if( GFootprintList.GetCount() == 0 )
|
||||||
{
|
|
||||||
GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
|
GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
|
||||||
}
|
|
||||||
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
|
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
|
||||||
progressReporter.Show( false );
|
progressReporter.Show( false );
|
||||||
|
|
||||||
|
|
|
@ -393,16 +393,18 @@ void FOOTPRINT_LIST_IMPL::ReadCacheFromFile( const wxString& aFilePath )
|
||||||
|
|
||||||
while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
|
while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
|
||||||
{
|
{
|
||||||
wxString libNickname = cacheFile.GetNextLine();
|
wxString libNickname = cacheFile.GetNextLine();
|
||||||
wxString name = cacheFile.GetNextLine();
|
wxString name = cacheFile.GetNextLine();
|
||||||
wxString description = UnescapeString( cacheFile.GetNextLine() );
|
wxString desc = UnescapeString( cacheFile.GetNextLine() );
|
||||||
wxString keywords = UnescapeString( cacheFile.GetNextLine() );
|
wxString keywords = UnescapeString( cacheFile.GetNextLine() );
|
||||||
int orderNum = wxAtoi( cacheFile.GetNextLine() );
|
int orderNum = wxAtoi( cacheFile.GetNextLine() );
|
||||||
unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
|
unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
|
||||||
unsigned int uniquePadCount = (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 );
|
||||||
|
|
||||||
auto* fpinfo = new FOOTPRINT_INFO_IMPL( libNickname, name, description, keywords,
|
|
||||||
orderNum, padCount, uniquePadCount );
|
|
||||||
m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
|
m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue