From b6a044111b49bc7ca883db31839b48fd7ea34f6a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 5 Jun 2023 11:00:03 +0100 Subject: [PATCH] Exclude redraws during closing (particularly of RATSNEST_VIEW_ITEM). (cherry picked from commit 7a3a8b67c1ecee3618e604410ced376ad839ddbf) --- pcbnew/initpcb.cpp | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 08d95f3612..36c7150f18 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -22,13 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file pcbnew/initpcb.cpp - */ - #include #include #include +#include #include #include @@ -89,6 +86,15 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal ) Zoom_Automatique( false ); } + else if( m_isClosing ) + { + if( m_toolManager ) + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); + + // Clear the view so we don't attempt redraws (particularly of the RATSNEST_VIEW_ITEM, + // which causes all manner of grief). + GetCanvas()->GetView()->Clear(); + } return true; } @@ -123,19 +129,30 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) ClearUndoRedoList(); GetScreen()->SetContentModified( false ); - BOARD* board = new BOARD; + if( !m_isClosing ) + { + SetBoard( new BOARD ); - board->GetDesignSettings() = GetDesignSettings(); - board->SynchronizeNetsAndNetClasses( true ); - SetBoard( board ); + GetBoard()->GetDesignSettings() = GetDesignSettings(); + GetBoard()->SynchronizeNetsAndNetClasses( true ); - // This board will only be used to hold a footprint for editing - GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); + // This board will only be used to hold a footprint for editing + GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); - // clear filename, to avoid overwriting an old file - GetBoard()->SetFileName( wxEmptyString ); + // clear filename, to avoid overwriting an old file + GetBoard()->SetFileName( wxEmptyString ); + + GetScreen()->InitDataPoints( GetPageSizeIU() ); + } + else + { + if( m_toolManager ) + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); + + // Clear the view so we don't attempt redraws + GetCanvas()->GetView()->Clear(); + } - GetScreen()->InitDataPoints( GetPageSizeIU() ); return true; }