← Back to team overview

kicad-developers team mailing list archive

[PATCH] Regression fix for pcbnew track cleanup

 

​This ​patch fixes a regression in commit 5c0edbaba (wow, that was a ways
back).  Currently, pcbnew will cleanup duplicate tracks by deleting both
tracks, rather than just one of the duplicates.  This patch ensures only
one of the two tracks will be deleted.

Fixes:
https://bugs.launchpad.net/kicad/+bug/1724728


-S
From ee7344d7bfa3cde9b330b6402b66035576f006ab Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Thu, 19 Oct 2017 14:09:58 -0700
Subject: [PATCH] pcbnew: Only remove one duplicate track -- not both

Fixes: lp:1724728
* https://bugs.launchpad.net/kicad/+bug/1724728
---
 pcbnew/clean.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp
index 05c34ea94..5e52049d1 100644
--- a/pcbnew/clean.cpp
+++ b/pcbnew/clean.cpp
@@ -444,6 +444,8 @@ bool TRACKS_CLEANER::deleteNullSegments()
 
 void TRACKS_CLEANER::removeDuplicatesOfTrack( const TRACK *aTrack, std::set<BOARD_ITEM*>& aToRemove )
 {
+    if( aTrack->GetFlags() & STRUCT_DELETED )
+        return;
 
     for( auto other : m_brd->Tracks() )
     {
@@ -454,6 +456,9 @@ void TRACKS_CLEANER::removeDuplicatesOfTrack( const TRACK *aTrack, std::set<BOAR
         if( aTrack == other )
             continue;
 
+        if( other->GetFlags() & STRUCT_DELETED )
+            continue;
+
         // Must be of the same type, on the same layer and the endpoints
         // must be the same (maybe swapped)
         if( ( aTrack->Type() == other->Type() ) &&
@@ -464,6 +469,7 @@ void TRACKS_CLEANER::removeDuplicatesOfTrack( const TRACK *aTrack, std::set<BOAR
                 ( ( aTrack->GetStart() == other->GetEnd() ) &&
                  ( aTrack->GetEnd() == other->GetStart() ) ) )
             {
+                other->SetFlags( STRUCT_DELETED );
                 aToRemove.insert( other );
             }
         }
-- 
2.11.0


Follow ups