Move timestamp setting where it will alwasy get set.
Also update the rest of the symbol-chooser usage to current specs, including examining the timestamp to see if the list needs loading at all. Partial fix to: lp:1760936 * https://bugs.launchpad.net/kicad/+bug/1760936
This commit is contained in:
parent
70988271c1
commit
5e36fe8df7
|
@ -101,15 +101,17 @@ void FOOTPRINT_SELECT_WIDGET::Load( KIWAY& aKiway, PROJECT& aProject )
|
|||
try
|
||||
{
|
||||
auto fp_lib_table = aProject.PcbFootprintLibs( aKiway );
|
||||
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
|
||||
|
||||
if( m_fp_loader.GetProgress() == 0 || !m_fp_loader.IsSameTable( fp_lib_table ) )
|
||||
if( m_fp_list->RequiresLoading( fp_lib_table ) )
|
||||
{
|
||||
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
|
||||
m_fp_loader.SetList( &*m_fp_list );
|
||||
m_fp_loader.Start( fp_lib_table );
|
||||
}
|
||||
|
||||
m_progress_timer->Start( 200 );
|
||||
m_progress_timer->Start( 200 );
|
||||
}
|
||||
else
|
||||
FootprintsLoaded();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
@ -128,18 +130,27 @@ void FOOTPRINT_SELECT_WIDGET::OnProgressTimer( wxTimerEvent& aEvent )
|
|||
wxBusyCursor busy;
|
||||
|
||||
m_fp_loader.Join();
|
||||
m_fp_filter.SetList( *m_fp_list );
|
||||
m_progress_timer->Stop();
|
||||
|
||||
m_book->SetSelection( PAGE_SELECT );
|
||||
m_finished_loading = true;
|
||||
|
||||
if( m_update )
|
||||
UpdateList();
|
||||
FootprintsLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_SELECT_WIDGET::FootprintsLoaded()
|
||||
{
|
||||
m_progress_ctrl->SetValue( 100 );
|
||||
|
||||
m_fp_filter.SetList( *m_fp_list );
|
||||
|
||||
m_book->SetSelection( PAGE_SELECT );
|
||||
m_finished_loading = true;
|
||||
|
||||
if( m_update )
|
||||
UpdateList();
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_SELECT_WIDGET::OnComboBox( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxCommandEvent evt( EVT_FOOTPRINT_SELECTED );
|
||||
|
|
|
@ -242,6 +242,15 @@ public:
|
|||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not the table requires loading for the given \a aNickname.
|
||||
*/
|
||||
virtual bool RequiresLoading( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr )
|
||||
{
|
||||
return true; // Implementations which support caching should implement this.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read all the footprints provided by the combination of aTable and aNickname.
|
||||
*
|
||||
|
|
|
@ -149,6 +149,7 @@ private:
|
|||
FOOTPRINT_FILTER m_fp_filter;
|
||||
bool m_zero_filter;
|
||||
|
||||
void FootprintsLoaded();
|
||||
void OnProgressTimer( wxTimerEvent& aEvent );
|
||||
void OnComboBox( wxCommandEvent& aEvent );
|
||||
void OnComboInteractive( wxCommandEvent& aEvent );
|
||||
|
|
|
@ -115,6 +115,12 @@ void FOOTPRINT_LIST_IMPL::loader_job()
|
|||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_LIST_IMPL::RequiresLoading( FP_LIB_TABLE* aTable, const wxString* aNickname )
|
||||
{
|
||||
return m_list_timestamp != aTable->GenerateTimestamp( aNickname );
|
||||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname,
|
||||
WX_PROGRESS_REPORTER* aProgressReporter )
|
||||
{
|
||||
|
@ -166,7 +172,6 @@ bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxStri
|
|||
( _( "Loading incomplete; cancelled by user." ), nullptr, nullptr, 0 ) );
|
||||
}
|
||||
|
||||
m_list_timestamp = aTable->GenerateTimestamp( aNickname );;
|
||||
m_progress_reporter = nullptr;
|
||||
|
||||
return m_errors.empty();
|
||||
|
@ -178,6 +183,7 @@ void FOOTPRINT_LIST_IMPL::StartWorkers( FP_LIB_TABLE* aTable, wxString const* aN
|
|||
{
|
||||
m_loader = aLoader;
|
||||
m_lib_table = aTable;
|
||||
m_library = aNickname;
|
||||
|
||||
// Clear data before reading files
|
||||
m_count_finished.store( 0 );
|
||||
|
@ -292,6 +298,11 @@ bool FOOTPRINT_LIST_IMPL::JoinWorkers()
|
|||
[]( std::unique_ptr<FOOTPRINT_INFO> const& lhs,
|
||||
std::unique_ptr<FOOTPRINT_INFO> const& rhs ) -> bool { return *lhs < *rhs; } );
|
||||
|
||||
if( m_cancelled )
|
||||
m_list_timestamp = 0; // God knows what we got before we were cancelled
|
||||
else
|
||||
m_list_timestamp = m_lib_table->GenerateTimestamp( m_library );;
|
||||
|
||||
return m_errors.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ protected:
|
|||
class FOOTPRINT_LIST_IMPL : public FOOTPRINT_LIST
|
||||
{
|
||||
FOOTPRINT_ASYNC_LOADER* m_loader;
|
||||
const wxString* m_library;
|
||||
std::vector<std::thread> m_threads;
|
||||
SYNC_QUEUE<wxString> m_queue_in;
|
||||
SYNC_QUEUE<wxString> m_queue_out;
|
||||
|
@ -89,8 +90,10 @@ public:
|
|||
FOOTPRINT_LIST_IMPL();
|
||||
virtual ~FOOTPRINT_LIST_IMPL();
|
||||
|
||||
virtual bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
|
||||
WX_PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
|
||||
bool RequiresLoading( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr ) override;
|
||||
|
||||
bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
|
||||
WX_PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
|
||||
};
|
||||
|
||||
extern FOOTPRINT_LIST_IMPL GFootprintList; // KIFACE scope.
|
||||
|
|
Loading…
Reference in New Issue