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
This commit is contained in:
Seth Hillbrand 2022-01-28 16:31:41 -08:00
parent 8ae304dcca
commit 8753051db6
2 changed files with 6 additions and 3 deletions

View File

@ -210,6 +210,8 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities
m_view->UnselectAll(); m_view->UnselectAll();
} }
BeforeReset();
if( aProvider != m_rcItemsProvider ) if( aProvider != m_rcItemsProvider )
{ {
delete 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 // Must be called after a significant change of items to force the
// wxDataViewModel to reread all of them, repopulating itself entirely. // wxDataViewModel to reread all of them, repopulating itself entirely.
Cleared(); AfterReset();
#ifdef __WXGTK__ #ifdef __WXGTK__
// The fastest method to update wxDataViewCtrl is to rebuild from // The fastest method to update wxDataViewCtrl is to rebuild from

View File

@ -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(), rtree.QueryColliding( track, track->GetLayer(), track->GetLayer(),
// Filter: // Filter:
@ -362,7 +362,8 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
{ {
return aItem->Type() == PCB_TRACE_T return aItem->Type() == PCB_TRACE_T
&& !aItem->HasFlag( SKIP_STRUCT ) && !aItem->HasFlag( SKIP_STRUCT )
&& !aItem->HasFlag( IS_DELETED ); && !aItem->HasFlag( IS_DELETED )
&& !static_cast<PCB_TRACK*>( aItem )->IsNull();
}, },
// Visitor: // Visitor:
[&]( BOARD_ITEM* aItem ) -> bool [&]( BOARD_ITEM* aItem ) -> bool