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,6 +60,8 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
|||
bool showGrid = IsElementVisible( LAYER_GRID );
|
||||
bool showRats = IsElementVisible( LAYER_RATSNEST );
|
||||
|
||||
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() );
|
||||
|
@ -87,6 +89,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
|||
UpdateTitle();
|
||||
|
||||
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