Browse Source

Avoid updating max clearance while in dtor

Max clearance is updated by IncrementTimeStamp(), which is called when in the FOOTPRINT dtor and ZONE dtor.  This can cause issues when iterating over all footprints as the footprints may be delete-ed

Fixes https://gitlab.com/kicad/code/kicad/issues/17269
newinvert
Yon Uriarte 2 years ago
committed by Seth Hillbrand
parent
commit
7520a8b316
  1. 12
      pcbnew/board.cpp
  2. 2
      pcbnew/board.h

12
pcbnew/board.cpp

@ -80,7 +80,7 @@ BOARD::BOARD() :
m_project( nullptr ), m_project( nullptr ),
m_userUnits( EDA_UNITS::MILLIMETRES ), m_userUnits( EDA_UNITS::MILLIMETRES ),
m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ), m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ),
m_deleting( false ),
m_skipMaxClearanceCacheUpdate( false ),
m_maxClearanceValue( 0 ), m_maxClearanceValue( 0 ),
m_NetInfo( this ) m_NetInfo( this )
{ {
@ -133,7 +133,7 @@ BOARD::BOARD() :
BOARD::~BOARD() BOARD::~BOARD()
{ {
m_deleting = true;
m_skipMaxClearanceCacheUpdate = true;
// Untangle group parents before doing any deleting // Untangle group parents before doing any deleting
for( PCB_GROUP* group : m_groups ) for( PCB_GROUP* group : m_groups )
@ -780,8 +780,8 @@ BOARD_DESIGN_SETTINGS& BOARD::GetDesignSettings() const
void BOARD::UpdateMaxClearanceCache() void BOARD::UpdateMaxClearanceCache()
{ {
// in destructor, useless work
if( m_deleting )
// in destructor or otherwise reasonable to skip
if( m_skipMaxClearanceCacheUpdate )
return; return;
int worstClearance = m_designSettings->GetBiggestClearanceValue(); int worstClearance = m_designSettings->GetBiggestClearanceValue();
@ -1121,10 +1121,14 @@ void BOARD::DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions )
void BOARD::DeleteAllFootprints() void BOARD::DeleteAllFootprints()
{ {
m_skipMaxClearanceCacheUpdate = true;
for( FOOTPRINT* footprint : m_footprints ) for( FOOTPRINT* footprint : m_footprints )
delete footprint; delete footprint;
m_footprints.clear(); m_footprints.clear();
m_skipMaxClearanceCacheUpdate = false;
UpdateMaxClearanceCache();
} }

2
pcbnew/board.h

@ -1320,7 +1320,7 @@ private:
*/ */
bool m_legacyTeardrops = false; bool m_legacyTeardrops = false;
bool m_deleting; // inside destructor
bool m_skipMaxClearanceCacheUpdate;
int m_maxClearanceValue; // cached value int m_maxClearanceValue; // cached value
NETINFO_LIST m_NetInfo; // net info list (name, design constraints... NETINFO_LIST m_NetInfo; // net info list (name, design constraints...

Loading…
Cancel
Save