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 177 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 184 of file footprint_preview_panel.cpp.

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

Definition at line 190 of file footprint_preview_panel.cpp.

191  {}

Member Function Documentation

virtual void* FP_LOADER_THREAD::Entry ( )
inlineoverridevirtual

Definition at line 228 of file footprint_preview_panel.cpp.

References ProcessEntry().

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

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


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