From 63fb408478f8cccb73ddf15ecab3893c9bfc5afc Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 2 Jun 2019 07:26:32 -0700 Subject: [PATCH] pcbnew: Don't modify the board lists outside of class We should not be updating the board lists without using the class_board methods. Fixes: lp:1831370 * https://bugs.launchpad.net/kicad/+bug/1831370 --- pcbnew/drc.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index c0ca9022d2..47e6dbb69a 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -1475,25 +1475,20 @@ void DRC::doFootprintOverlappingDrc() void DRC::TestFootprints( NETLIST& aNetlist, BOARD* aPCB, EDA_UNITS_T aUnits, DRC_LIST& aDRCList ) { - auto mods = aPCB->Modules(); - std::sort( mods.begin(), mods.end(), []( const MODULE* a, const MODULE* b ) { - return a->GetReference().CmpNoCase( b->GetReference() ); - } ); + // Search for duplicate footprints on the board + auto comp = []( const MODULE* x, const MODULE* y ) { + return x->GetReference().CmpNoCase( y->GetReference() ) < 0; + }; + auto mods = std::set( comp ); - // Search for duplicate footprints. - for( auto it = mods.begin(); it != mods.end(); it++ ) + for( auto mod : aPCB->Modules() ) { - auto next_it = it + 1; - - if( next_it == mods.end() ) - break; - - if( ( *it )->GetReference().CmpNoCase( ( *next_it )->GetReference() ) == 0 ) + auto ins = mods.insert( mod ); + if( !ins.second ) { - aDRCList.emplace_back( new DRC_ITEM( aUnits, DRCE_DUPLICATE_FOOTPRINT, *it, - ( *it )->GetPosition(), *next_it, ( *next_it )->GetPosition() ) ); - break; + aDRCList.emplace_back( new DRC_ITEM( aUnits, DRCE_DUPLICATE_FOOTPRINT, mod, + mod->GetPosition(), *ins.first, ( *ins.first )->GetPosition() ) ); } }