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 (FOOTPRINT_PREVIEW_PANEL *aParent, 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

FOOTPRINT_PREVIEW_PANELm_parent
 
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 130 of file footprint_preview_panel.cpp.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 138 of file footprint_preview_panel.cpp.

139  :
140  wxThread( wxTHREAD_DETACHED ),
141  m_parent( aParent ),
142  m_iface( aIface )
143  {}
FOOTPRINT_PREVIEW_PANEL * m_parent
std::shared_ptr< FP_THREAD_IFACE > m_iface
FP_LOADER_THREAD::~FP_LOADER_THREAD ( )
inline

Definition at line 146 of file footprint_preview_panel.cpp.

147  {}

Member Function Documentation

virtual void* FP_LOADER_THREAD::Entry ( )
inlineoverridevirtual

Definition at line 186 of file footprint_preview_panel.cpp.

References ProcessEntry().

187  {
188  while( !TestDestroy() )
189  {
190  auto ent = m_iface->PopFromQueue();
191 
192  if( ent )
193  ProcessEntry( *ent );
194  else
195  wxMilliSleep( 100 );
196  }
197 
198  return NULL;
199  }
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 150 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, PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), and FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY::status.

Referenced by Entry().

151  {
153 
154  if( !fptbl )
155  return;
156 
157  aEntry.module = NULL;
158 
159  try {
160  aEntry.module = fptbl->FootprintLoadWithOptionalNickname( aEntry.fpid );
161 
162  if( !aEntry.module )
163  aEntry.status = FPS_NOT_FOUND;
164 
165  } catch( const IO_ERROR& ioe )
166  {
167  aEntry.status = FPS_NOT_FOUND;
168  }
169 
170 
171  if( aEntry.status != FPS_NOT_FOUND )
172  aEntry.status = FPS_READY;
173 
174  m_iface->AddToCache( aEntry );
175 
176  if( aEntry.fpid == m_iface->GetCurrentFootprint() )
177  {
178  auto handler = m_parent->GetEventHandler();
179 
180  if( handler )
181  handler->QueueEvent( new wxCommandEvent( wxEVT_COMMAND_TEXT_UPDATED, 1 ) );
182  }
183  }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
FOOTPRINT_PREVIEW_PANEL * m_parent
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 135 of file footprint_preview_panel.cpp.

FOOTPRINT_PREVIEW_PANEL* FP_LOADER_THREAD::m_parent
private

Definition at line 134 of file footprint_preview_panel.cpp.


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