KiCad PCB EDA Suite
FP_LOADER_THREAD Class Reference

Footprint loader thread to prevent footprint loading from locking the UI. More...

Inheritance diagram for FP_LOADER_THREAD:

Public Member Functions

 FP_LOADER_THREAD (std::shared_ptr< FP_THREAD_IFACE > const &aIface)
 
 ~FP_LOADER_THREAD ()
 
void ProcessEntry (CACHE_ENTRY &aEntry)
 
virtual void * Entry () override
 

Private Types

using CACHE_ENTRY = FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY
 

Private Attributes

std::shared_ptr< FP_THREAD_IFACEm_iface
 

Detailed Description

Footprint loader thread to prevent footprint loading from locking the UI.

Interface is via a FP_THREAD_IFACE.

Definition at line 179 of file footprint_preview_panel.cpp.

Member Typedef Documentation

Constructor & Destructor Documentation

FP_LOADER_THREAD::FP_LOADER_THREAD ( std::shared_ptr< FP_THREAD_IFACE > const &  aIface)
inline

Definition at line 186 of file footprint_preview_panel.cpp.

186  :
187  wxThread( wxTHREAD_DETACHED ),
188  m_iface( aIface )
189  {}
std::shared_ptr< FP_THREAD_IFACE > m_iface
FP_LOADER_THREAD::~FP_LOADER_THREAD ( )
inline

Definition at line 192 of file footprint_preview_panel.cpp.

193  {}

Member Function Documentation

virtual void* FP_LOADER_THREAD::Entry ( )
inlineoverridevirtual

Definition at line 230 of file footprint_preview_panel.cpp.

231  {
232  while( m_iface->GetPanel() )
233  {
234  auto ent = m_iface->PopFromQueue();
235 
236  if( ent )
237  ProcessEntry( *ent );
238  else
239  wxMilliSleep( 100 );
240  }
241 
242  return nullptr;
243  }
void ProcessEntry(CACHE_ENTRY &aEntry)
std::shared_ptr< FP_THREAD_IFACE > m_iface
void FP_LOADER_THREAD::ProcessEntry ( CACHE_ENTRY aEntry)
inline

Definition at line 196 of file footprint_preview_panel.cpp.

References FP_LIB_TABLE::FootprintLoadWithOptionalNickname(), FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY::fpid, FPS_NOT_FOUND, FPS_READY, FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY::module, and FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY::status.

197  {
198  FP_LIB_TABLE* fptbl = m_iface->GetTable();
199 
200  if( !fptbl )
201  return;
202 
203  aEntry.module = NULL;
204 
205  try {
206  aEntry.module = fptbl->FootprintLoadWithOptionalNickname( aEntry.fpid );
207 
208  if( !aEntry.module )
209  aEntry.status = FPS_NOT_FOUND;
210 
211  } catch( const IO_ERROR& )
212  {
213  aEntry.status = FPS_NOT_FOUND;
214  }
215 
216 
217  if( aEntry.status != FPS_NOT_FOUND )
218  aEntry.status = FPS_READY;
219 
220  m_iface->AddToCache( aEntry );
221 
222  if( aEntry.fpid == m_iface->GetCurrentFootprint() )
223  {
224  wxCommandEvent evt( wxEVT_COMMAND_TEXT_UPDATED, 1 );
225  m_iface->QueueEvent( evt );
226  }
227  }
std::shared_ptr< FP_THREAD_IFACE > m_iface
MODULE * FootprintLoadWithOptionalNickname(const LIB_ID &aFootprintId)
Function FootprintLoadWithOptionalNickname loads a footprint having aFootprintId with possibly an emp...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

Member Data Documentation

std::shared_ptr<FP_THREAD_IFACE> FP_LOADER_THREAD::m_iface
private

Definition at line 183 of file footprint_preview_panel.cpp.


The documentation for this class was generated from the following file: