From 8753051db66e93cdb9c5c3c22292931f1a013341 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 28 Jan 2022 16:31:41 -0800 Subject: [PATCH] Don't count zero-length as duplicate We were checking for duplicate tracks by looking to see if the two tracks had two shared points. A null track always matched this case, which removed the valid track. We solve this by avoiding null tracks in the duplicate checker. They are removed separately in the null track stage. This also fixes a GTK-specific tree issue where we require the BeforeReset()/AfterReset() calls instead of Cleared() to prevent GTK from dereferencing a parent after freeing Fixes https://gitlab.com/kicad/code/kicad/issues/10624 --- common/rc_item.cpp | 4 +++- pcbnew/tracks_cleaner.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/rc_item.cpp b/common/rc_item.cpp index 4edc851ed4..3171492aec 100644 --- a/common/rc_item.cpp +++ b/common/rc_item.cpp @@ -210,6 +210,8 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities m_view->UnselectAll(); } + BeforeReset(); + if( aProvider != m_rcItemsProvider ) { delete m_rcItemsProvider; @@ -255,7 +257,7 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities // Must be called after a significant change of items to force the // wxDataViewModel to reread all of them, repopulating itself entirely. - Cleared(); + AfterReset(); #ifdef __WXGTK__ // The fastest method to update wxDataViewCtrl is to rebuild from diff --git a/pcbnew/tracks_cleaner.cpp b/pcbnew/tracks_cleaner.cpp index 0799f3d321..2c4ea7154d 100644 --- a/pcbnew/tracks_cleaner.cpp +++ b/pcbnew/tracks_cleaner.cpp @@ -354,7 +354,7 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment } } - if( aDeleteDuplicateSegments && track->Type() == PCB_TRACE_T ) + if( aDeleteDuplicateSegments && track->Type() == PCB_TRACE_T && !track->IsNull() ) { rtree.QueryColliding( track, track->GetLayer(), track->GetLayer(), // Filter: @@ -362,7 +362,8 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment { return aItem->Type() == PCB_TRACE_T && !aItem->HasFlag( SKIP_STRUCT ) - && !aItem->HasFlag( IS_DELETED ); + && !aItem->HasFlag( IS_DELETED ) + && !static_cast( aItem )->IsNull(); }, // Visitor: [&]( BOARD_ITEM* aItem ) -> bool