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 176 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 183 of file footprint_preview_panel.cpp.

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

Definition at line 189 of file footprint_preview_panel.cpp.

190  {}

Member Function Documentation

virtual void* FP_LOADER_THREAD::Entry ( )
inlineoverridevirtual

Definition at line 227 of file footprint_preview_panel.cpp.

References ProcessEntry().

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

Referenced by Entry().

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


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