mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 22:23:43 +00:00
Pcbnew: fp load: tidy up FOOTPRINT_SELECT_WIDGET::Load
The call to FOOTPRINT_LIST::GetInstance( aKiway ) returns a null pointer when it fails, rather than throwing. So this wouldn't actually catch a KiWay failure and avert a segfault. And no other caller of ReadFootprintFiles is in a try - so either this function won't throw, or if it does, all callsites need updating. For now, go with the majority.
This commit is contained in:
parent
5acf60ec6c
commit
e24d43178a
common/widgets
kicad
pcbnew
@ -57,30 +57,22 @@ FOOTPRINT_SELECT_WIDGET::FOOTPRINT_SELECT_WIDGET( EDA_DRAW_FRAME* aFrame, wxWind
|
||||
|
||||
void FOOTPRINT_SELECT_WIDGET::Load( KIWAY& aKiway, PROJECT& aProject )
|
||||
{
|
||||
try
|
||||
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
|
||||
wxCHECK_MSG( m_fp_list, /* void */, "Failed to get the footprint list from the KiWay" );
|
||||
|
||||
if( m_fp_list->GetCount() == 0 )
|
||||
{
|
||||
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
|
||||
// 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 );
|
||||
WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Loading Footprint Libraries" ), 3 );
|
||||
FOOTPRINT_LIST_IMPL& fpList = static_cast<FOOTPRINT_LIST_IMPL&>( *m_fp_list );
|
||||
|
||||
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 );
|
||||
WX_PROGRESS_REPORTER* progressReporter =
|
||||
new WX_PROGRESS_REPORTER( m_frame, _( "Loading Footprint Libraries" ), 3 );
|
||||
static_cast<FOOTPRINT_LIST_IMPL*>( m_fp_list )
|
||||
->ReadFootprintFiles( fpTable, nullptr, progressReporter );
|
||||
|
||||
delete progressReporter;
|
||||
}
|
||||
|
||||
m_fp_filter.SetList( *m_fp_list );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// no footprint libraries available
|
||||
fpList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
|
||||
}
|
||||
|
||||
m_fp_filter.SetList( *m_fp_list );
|
||||
|
||||
if( m_update )
|
||||
UpdateList();
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ bool WX_PROGRESS_REPORTER::updateUI()
|
||||
m_messageChanged = false;
|
||||
}
|
||||
|
||||
// Returns false when cancelled (if it's a cancellable dialog)
|
||||
bool diag = wxProgressDialog::Update( cur, message );
|
||||
|
||||
return diag;
|
||||
|
@ -729,7 +729,6 @@ void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreat
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,6 @@ bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxStri
|
||||
m_queue_in.push( nickname );
|
||||
}
|
||||
|
||||
|
||||
loadLibs();
|
||||
|
||||
if( !m_cancelled )
|
||||
|
Loading…
Reference in New Issue
Block a user