Attempt fix to RATSNEST crash

We call 'RecalculateRatsnest' in multiple locations, this will
invalidate various pointers needed by VIEW::Redraw().  When this is
called through the normal connectivity routines, we have the mutex
locked to prevent conflict but we've added more locations that update
just the Ratsnest.  The std::adopt_lock should take over the existing
lock when needed

Fixes https://gitlab.com/kicad/code/kicad/issues/13011
This commit is contained in:
Seth Hillbrand 2023-01-26 17:30:34 -08:00
parent 42b4f49e7f
commit a0236113da
1 changed files with 8 additions and 0 deletions

View File

@ -205,6 +205,14 @@ void CONNECTIVITY_DATA::addRatsnestCluster( const std::shared_ptr<CN_CLUSTER>& a
void CONNECTIVITY_DATA::RecalculateRatsnest( BOARD_COMMIT* aCommit )
{
// We can take over the lock here if called in the same thread
// This is to prevent redraw during a RecalculateRatsnets process
std::unique_lock<KISPINLOCK> lock( m_lock, std::adopt_lock );
if( !lock )
return;
m_connAlgo->PropagateNets( aCommit );
int lastNet = m_connAlgo->NetCount();