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 (const std::shared_ptr< FP_THREAD_IFACE > &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 184 of file footprint_preview_panel.cpp.

Member Typedef Documentation

◆ CACHE_ENTRY

Constructor & Destructor Documentation

◆ FP_LOADER_THREAD()

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

Definition at line 191 of file footprint_preview_panel.cpp.

192  : wxThread( wxTHREAD_DETACHED ), m_iface( aIface )
193  {
194  }
std::shared_ptr< FP_THREAD_IFACE > m_iface

◆ ~FP_LOADER_THREAD()

FP_LOADER_THREAD::~FP_LOADER_THREAD ( )
inline

Definition at line 197 of file footprint_preview_panel.cpp.

198  {
199  }

Member Function Documentation

◆ Entry()

virtual void* FP_LOADER_THREAD::Entry ( )
inlineoverridevirtual

Definition at line 234 of file footprint_preview_panel.cpp.

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

References m_iface, and ProcessEntry().

◆ ProcessEntry()

void FP_LOADER_THREAD::ProcessEntry ( CACHE_ENTRY aEntry)
inline

Definition at line 202 of file footprint_preview_panel.cpp.

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

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

Referenced by Entry().

Member Data Documentation

◆ m_iface

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

Definition at line 188 of file footprint_preview_panel.cpp.

Referenced by Entry(), and ProcessEntry().


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