Fix race condition in zone fill
When checking collisions, the SHAPE_POLY_SET::Collide() routine is not const because it will regenerate the triangulation cache if it is out of date (using a const_cast, grrr). This sidesteps the issue by assigning a mutex to the triangulation caching Fixes https://gitlab.com/kicad/code/kicad/-/issues/17180
This commit is contained in:
parent
4f4d9be8d1
commit
81cb6d0c3f
|
@ -32,6 +32,7 @@
|
|||
#include <deque> // for deque
|
||||
#include <iosfwd> // for string, stringstream
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set> // for set
|
||||
#include <stdexcept> // for out_of_range
|
||||
#include <stdlib.h> // for abs
|
||||
|
@ -1537,7 +1538,8 @@ protected:
|
|||
std::vector<POLYGON> m_polys;
|
||||
std::vector<std::unique_ptr<TRIANGULATED_POLYGON>> m_triangulatedPolys;
|
||||
|
||||
bool m_triangulationValid = false;
|
||||
bool m_triangulationValid = false;
|
||||
std::mutex m_triangulationMutex;
|
||||
|
||||
private:
|
||||
MD5_HASH m_hash;
|
||||
|
|
|
@ -2984,6 +2984,7 @@ static SHAPE_POLY_SET partitionPolyIntoRegularCellGrid( const SHAPE_POLY_SET& aP
|
|||
void SHAPE_POLY_SET::cacheTriangulation( bool aPartition, bool aSimplify,
|
||||
std::vector<std::unique_ptr<TRIANGULATED_POLYGON>>* aHintData )
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( m_triangulationMutex );
|
||||
bool recalculate = !m_hash.IsValid();
|
||||
MD5_HASH hash;
|
||||
|
||||
|
|
Loading…
Reference in New Issue