From 3e54e16bdceedd2d96bafd7728cdb223df8a6876 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 5 Mar 2018 16:37:39 +0100 Subject: [PATCH] Update ratsnest after a footprint change PCB_BASE_FRAME::PlaceModule() calls CN_CONNECTIVITY_ALGO::Update() on the new footprint that does not have nets assigned. The Update() method first removes the footprint (but it has not been added, so nothing happens) and then adds it with all pads marked as not connected. Later, when BOARD_COMMIT is pushed - it tries to add the same footprint again with nets assigned, but the pads are already registered, therefore they are discarded. To prevent this, PlaceModule() does not call CN_CONNECTIVITY_ALGO::Update() for the just created footprint, as it is handled by BOARD_COMMIT later. --- pcbnew/board_commit.cpp | 5 +++-- pcbnew/pcb_footprint_edit_utils.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 57a5d62515..57e0e6800f 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -119,7 +119,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry ) } if( !( changeFlags & CHT_DONE ) ) - board->Add( boardItem ); + board->Add( boardItem ); // handles connectivity } else @@ -128,6 +128,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry ) wxASSERT( boardItem->Type() != PCB_MODULE_T ); boardItem->SetParent( board->m_Modules.GetFirst() ); + if( !( changeFlags & CHT_DONE ) ) board->m_Modules->Add( boardItem ); } @@ -226,7 +227,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry ) view->Remove( module ); if( !( changeFlags & CHT_DONE ) ) - board->Remove( module ); + board->Remove( module ); // handles connectivity // Clear flags to indicate, that the ratsnest, list of nets & pads are not valid anymore board->m_Status_Pcb = 0; diff --git a/pcbnew/pcb_footprint_edit_utils.cpp b/pcbnew/pcb_footprint_edit_utils.cpp index d54c806310..73239b65d3 100644 --- a/pcbnew/pcb_footprint_edit_utils.cpp +++ b/pcbnew/pcb_footprint_edit_utils.cpp @@ -411,7 +411,8 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aRecreateRats m_canvas->SetMouseCapture( NULL, NULL ); - m_Pcb->GetConnectivity()->Update( aModule ); + if( aRecreateRatsnest ) + m_Pcb->GetConnectivity()->Update( aModule ); if( GetBoard()->IsElementVisible( LAYER_RATSNEST ) && aRecreateRatsnest ) Compile_Ratsnest( aDC, true );