pcbnew: ClearPcb() without queuing tools
When exiting pcbnew, we only want to run the sections of ClearPcb that remove the old pcb data. We do not want to queue events that handle initializing a new pcb. These were caught after freeing memory in some cases, leading to segfaults. Fixes: lp:1831560 * https://bugs.launchpad.net/kicad/+bug/1831560
This commit is contained in:
parent
15241b7fcf
commit
f007d2857a
|
@ -36,7 +36,7 @@
|
|||
#include <footprint_edit_frame.h>
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
||||
bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal )
|
||||
{
|
||||
if( GetBoard() == NULL )
|
||||
return false;
|
||||
|
@ -60,33 +60,36 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
|||
bool showGrid = IsElementVisible( LAYER_GRID );
|
||||
bool showRats = IsElementVisible( LAYER_RATSNEST );
|
||||
|
||||
// delete the old BOARD and create a new BOARD so that the default
|
||||
// layer names are put into the BOARD.
|
||||
SetBoard( new BOARD() );
|
||||
SetElementVisibility( LAYER_GRID, showGrid );
|
||||
SetElementVisibility( LAYER_RATSNEST, showRats );
|
||||
if( !aFinal )
|
||||
{
|
||||
// delete the old BOARD and create a new BOARD so that the default
|
||||
// layer names are put into the BOARD.
|
||||
SetBoard( new BOARD() );
|
||||
SetElementVisibility( LAYER_GRID, showGrid );
|
||||
SetElementVisibility( LAYER_RATSNEST, showRats );
|
||||
|
||||
// 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() );
|
||||
GetScreen()->InitDataPoints( GetPageSizeIU() );
|
||||
|
||||
GetBoard()->ResetHighLight();
|
||||
GetBoard()->ResetHighLight();
|
||||
|
||||
// Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
|
||||
GetBoard()->SetEnabledLayers( LSET().set() );
|
||||
// Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
|
||||
GetBoard()->SetEnabledLayers( LSET().set() );
|
||||
|
||||
// Default copper layers count set to 2: double layer board
|
||||
GetBoard()->SetCopperLayerCount( 2 );
|
||||
// Default copper layers count set to 2: double layer board
|
||||
GetBoard()->SetCopperLayerCount( 2 );
|
||||
|
||||
// Update display (some options depend on the board setup)
|
||||
GetBoard()->SetVisibleLayers( LSET().set() );
|
||||
ReCreateLayerBox();
|
||||
ReCreateAuxiliaryToolbar();
|
||||
ReFillLayerWidget();
|
||||
UpdateTitle();
|
||||
// Update display (some options depend on the board setup)
|
||||
GetBoard()->SetVisibleLayers( LSET().set() );
|
||||
ReCreateLayerBox();
|
||||
ReCreateAuxiliaryToolbar();
|
||||
ReFillLayerWidget();
|
||||
UpdateTitle();
|
||||
|
||||
Zoom_Automatique( false );
|
||||
Zoom_Automatique( false );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -524,7 +524,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
|
||||
// Delete board structs and undo/redo lists, to avoid crash on exit
|
||||
// when deleting some structs (mainly in undo/redo lists) too late
|
||||
Clear_Pcb( false );
|
||||
Clear_Pcb( false, true );
|
||||
|
||||
// do not show the window because ScreenPcb will be deleted and we do not
|
||||
// want any paint event
|
||||
|
|
|
@ -672,8 +672,9 @@ public:
|
|||
* Function Clear_Pcb
|
||||
* delete all and reinitialize the current board
|
||||
* @param aQuery = true to prompt user for confirmation, false to initialize silently
|
||||
* @param aFinal = if true, we are clearing the board to exit, so don't run more events
|
||||
*/
|
||||
bool Clear_Pcb( bool aQuery );
|
||||
bool Clear_Pcb( bool aQuery, bool aFinal = false );
|
||||
|
||||
///> @copydoc PCB_BASE_FRAME::SetBoard()
|
||||
void SetBoard( BOARD* aBoard ) override;
|
||||
|
|
Loading…
Reference in New Issue