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 178 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 185 of file footprint_preview_panel.cpp.

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

Definition at line 191 of file footprint_preview_panel.cpp.

192  {}

Member Function Documentation

virtual void* FP_LOADER_THREAD::Entry ( )
inlineoverridevirtual

Definition at line 229 of file footprint_preview_panel.cpp.

230  {
231  while( m_iface->GetPanel() )
232  {
233  auto ent = m_iface->PopFromQueue();
234 
235  if( ent )
236  ProcessEntry( *ent );
237  else
238  wxMilliSleep( 100 );
239  }
240 
241  return nullptr;
242  }
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 195 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.

196  {
197  FP_LIB_TABLE* fptbl = m_iface->GetTable();
198 
199  if( !fptbl )
200  return;
201 
202  aEntry.module = NULL;
203 
204  try {
205  aEntry.module = fptbl->FootprintLoadWithOptionalNickname( aEntry.fpid );
206 
207  if( !aEntry.module )
208  aEntry.status = FPS_NOT_FOUND;
209 
210  } catch( const IO_ERROR& )
211  {
212  aEntry.status = FPS_NOT_FOUND;
213  }
214 
215 
216  if( aEntry.status != FPS_NOT_FOUND )
217  aEntry.status = FPS_READY;
218 
219  m_iface->AddToCache( aEntry );
220 
221  if( aEntry.fpid == m_iface->GetCurrentFootprint() )
222  {
223  wxCommandEvent evt( wxEVT_COMMAND_TEXT_UPDATED, 1 );
224  m_iface->QueueEvent( evt );
225  }
226  }
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:47

Member Data Documentation

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

Definition at line 182 of file footprint_preview_panel.cpp.


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