From 536451138dd931e019ee47bff7cc1e301f83293d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 Oct 2018 18:17:16 +0100 Subject: [PATCH] Make sure fixes to netlist stuff are done on both sides. This fixes the CmpNoCase() == 0 bug on one side, and the footprint == null bug on the other side; both of which were previously fixed on only one side. Fixes: lp:1795561 * https://bugs.launchpad.net/kicad/+bug/1795561 --- pcbnew/board_netlist_updater.cpp | 31 +++++++++++++------------------ pcbnew/class_board.cpp | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/pcbnew/board_netlist_updater.cpp b/pcbnew/board_netlist_updater.cpp index d7b99c43da..16e7acb200 100644 --- a/pcbnew/board_netlist_updater.cpp +++ b/pcbnew/board_netlist_updater.cpp @@ -632,6 +632,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) { COMPONENT* component = aNetlist.GetComponent( i ); int matchCount = 0; + MODULE* tmp; msg.Printf( _( "Processing component \"%s:%s:%s\"." ), component->GetReference(), @@ -639,12 +640,9 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) component->GetFPID().Format().wx_str() ); m_reporter->Report( msg, REPORTER::RPT_INFO ); - // This loop must be executed at least once to add new footprints even - // if the board has no existing footprints: - for( MODULE* footprint = m_board->m_Modules; ; footprint = footprint->Next() ) + for( MODULE* footprint = m_board->m_Modules; footprint; footprint = footprint->Next() ) { bool match = false; - MODULE* tmp; if( footprint ) { @@ -672,25 +670,22 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) if( footprint == lastPreexistingFootprint ) { - if( matchCount == 0 ) - { - tmp = addNewComponent( component ); - - if( tmp ) - { - updateComponentParameters( tmp, component ); - updateComponentPadConnections( tmp, component ); - } - - matchCount++; - } - // No sense going through the newly-created footprints: end of loop break; } } - if( matchCount > 1 ) + if( matchCount == 0 ) + { + tmp = addNewComponent( component ); + + if( tmp ) + { + updateComponentParameters( tmp, component ); + updateComponentPadConnections( tmp, component ); + } + } + else if( matchCount > 1 ) { msg.Printf( _( "Multiple footprints found for \"%s\"." ), component->GetReference() ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 851d16865a..32534129f9 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2575,7 +2575,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, if( aNetlist.IsFindByTimeStamp() ) match = footprint->GetPath() == component->GetTimeStamp(); else - match = footprint->GetReference().CmpNoCase( component->GetReference() ); + match = footprint->GetReference().CmpNoCase( component->GetReference() ) == 0; if( match ) {