Lock Connectivity Data when resetting

When we reset m_connAlgo, we need to lock the data mutex otherwise,
yields to the system may sometimes issue calls back to invalid data
until m_connAlgo has finished rebuilding

Fixes https://gitlab.com/kicad/code/kicad/issues/9922
This commit is contained in:
Seth Hillbrand 2021-12-11 15:09:53 -08:00
parent caf406943e
commit 758ce43d9c
1 changed files with 4 additions and 0 deletions

View File

@ -85,6 +85,8 @@ bool CONNECTIVITY_DATA::Update( BOARD_ITEM* aItem )
void CONNECTIVITY_DATA::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
{
std::unique_lock<KISPINLOCK> lock( m_lock );
m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
m_connAlgo->Build( aBoard, aReporter );
@ -100,6 +102,8 @@ void CONNECTIVITY_DATA::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
void CONNECTIVITY_DATA::Build( const std::vector<BOARD_ITEM*>& aItems )
{
std::unique_lock<KISPINLOCK> lock( m_lock );
m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
m_connAlgo->Build( aItems );