Protect courtyard cache regen
The courtyards are referenced by multiple calls and will be rebuilt on
command. If this happens during zone fill (because the board timestamp
has incremented since the start) multiple threads may generate the cache
at the same time, leaving one with an invalid pointer
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17791
(cherry picked from commit df5dd15c6f
)
This commit is contained in:
parent
798b827a12
commit
fdc3806ed1
|
@ -2551,6 +2551,8 @@ std::shared_ptr<SHAPE> FOOTPRINT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHI
|
|||
|
||||
const SHAPE_POLY_SET& FOOTPRINT::GetCourtyard( PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_courtyard_cache_mutex );
|
||||
|
||||
if( GetBoard() && GetBoard()->GetTimeStamp() > m_courtyard_cache_timestamp )
|
||||
const_cast<FOOTPRINT*>( this )->BuildCourtyardCaches();
|
||||
|
||||
|
|
|
@ -1025,6 +1025,7 @@ private:
|
|||
SHAPE_POLY_SET m_courtyard_cache_front; // Note that a footprint can have both front and back
|
||||
SHAPE_POLY_SET m_courtyard_cache_back; // courtyards populated.
|
||||
mutable int m_courtyard_cache_timestamp;
|
||||
mutable std::mutex m_courtyard_cache_mutex;
|
||||
};
|
||||
|
||||
#endif // FOOTPRINT_H
|
||||
|
|
Loading…
Reference in New Issue