From 16e802aff4c1f3738dc2b5d2cc2b55135b661ed2 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 (cherry picked from commit 8753051db66e93cdb9c5c3c22292931f1a013341) --- 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 15373c9f94..4c955d48e2 100644 --- a/common/rc_item.cpp +++ b/common/rc_item.cpp @@ -211,6 +211,8 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities m_view->UnselectAll(); } + BeforeReset(); + if( aProvider != m_rcItemsProvider ) { delete m_rcItemsProvider; @@ -256,7 +258,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 07ef350236..7ced9cc5ff 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