diff --git a/common/commit.cpp b/common/commit.cpp index 423f77278e..74bd697c6e 100644 --- a/common/commit.cpp +++ b/common/commit.cpp @@ -61,6 +61,9 @@ COMMIT& COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCREEN* aS return *this; case CHT_REMOVE: + wxASSERT_MSG( m_deletedItems.find( aItem ) == m_deletedItems.end(), + wxT( "Item already staged for deletion" ) ); + m_deletedItems.insert( aItem ); makeEntry( aItem, CHT_REMOVE | flag, nullptr, aScreen ); return *this; @@ -133,9 +136,8 @@ int COMMIT::GetStatus( EDA_ITEM* aItem, BASE_SCREEN *aScreen ) COMMIT& COMMIT::createModified( EDA_ITEM* aItem, EDA_ITEM* aCopy, int aExtraFlags, BASE_SCREEN* aScreen ) { EDA_ITEM* parent = parentObject( aItem ); - auto entryIt = m_changedItems.find( parent ); - if( entryIt != m_changedItems.end() ) + if( m_changedItems.find( parent ) != m_changedItems.end() ) { delete aCopy; return *this; // item has been already modified once diff --git a/include/commit.h b/include/commit.h index 9b2aae8186..aa89fcb89b 100644 --- a/include/commit.h +++ b/include/commit.h @@ -163,6 +163,7 @@ protected: void clear() { m_changedItems.clear(); + m_deletedItems.clear(); m_changes.clear(); } @@ -188,6 +189,7 @@ protected: protected: std::set m_changedItems; + std::set m_deletedItems; std::vector m_changes; }; diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index c7708de308..5d7cdd6b55 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -638,7 +638,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint // Create a copy only if the footprint has not been added during this update FOOTPRINT* copy = nullptr; - if( !m_commit.GetStatus( aFootprint ) ) + if( !m_isDryRun && !m_commit.GetStatus( aFootprint ) ) { copy = static_cast( aFootprint->Clone() ); copy->SetParentGroup( nullptr ); @@ -650,9 +650,11 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint PADS pads = aFootprint->Pads(); std::set padNetnames; - std::sort( pads.begin(), pads.end(), []( PAD* a, PAD* b ) { - return a->m_Uuid < b->m_Uuid; - } ); + std::sort( pads.begin(), pads.end(), + []( PAD* a, PAD* b ) + { + return a->m_Uuid < b->m_Uuid; + } ); for( PAD* pad : pads ) { @@ -1273,7 +1275,6 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) { msg.Printf( _( "Removed unused net %s." ), net->GetNetname() ); m_reporter->Report( msg, RPT_SEVERITY_ACTION ); - m_commit.Removed( net ); } }