Pcbnew: avoid crash when closing pcbnew if the DRC dialog is open.

Cvpcb: change from commit 9ceca583:
the root class close event that save settings is now seeing the close event.
This commit is contained in:
jean-pierre charras 2019-09-19 09:11:45 +02:00
parent bb596ebdaf
commit 16f4958430
6 changed files with 21 additions and 13 deletions

View File

@ -149,7 +149,7 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
wxConfigBase* cfg = config();
if( cfg )
SaveSettings( cfg ); // virtual, wxFrame specific
SaveSettings( cfg ); // virtual, wxFrame specific
event.Skip(); // we did not "handle" the event, only eavesdropped on it.
}

View File

@ -320,15 +320,9 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
// clear highlight symbol in schematic:
SendMessageToEESCHEMA( true );
// Save config. Because the wxCloseEvent is captured,
// the EDA_BASE_FRAME will not see the event and will not save the config.
wxConfigBase* cfg = config();
if( cfg )
SaveSettings( cfg );
// Delete window
Destroy();
// Skip the close event. Looks like needed to have the close event sent to the
// root class EDA_BASE_FRAME, and save config
Event.Skip();
}

View File

@ -56,6 +56,8 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFra
m_uviaMinSize( aEditorFrame, m_MicroViaMinTitle, m_SetMicroViakMinSizeCtrl,
m_MicroViaMinUnit, true )
{
SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
m_config = Kiface().KifaceSettings();
m_tester = aTester;
m_brdEditor = aEditorFrame;

View File

@ -46,6 +46,7 @@ class BOARD_DESIGN_SETTINGS;
/*!
* DrcDialog class declaration
*/
#define DIALOG_DRC_WINDOW_NAME "DialogDrcWindowName"
class DIALOG_DRC_CONTROL: public DIALOG_DRC_CONTROL_BASE
{

View File

@ -461,8 +461,8 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
Clear_Pcb( false );
//close the editor
Destroy();
// Close the editor
Event.Skip();
}

View File

@ -85,6 +85,7 @@
#include <netlist_reader.h>
#include <pcb_netlist.h>
#include <wx/wupdlock.h>
#include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
#include <python_scripting.h>
@ -460,6 +461,15 @@ void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
// First close the DRC dialog.
// For some reason, if the board editor frame is destroyed when the DRC
// dialog currently open, Pcbnew crashes, At least on Windows.
DIALOG_DRC_CONTROL* open_dlg = static_cast<DIALOG_DRC_CONTROL*>(
wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME ) );
if( open_dlg )
open_dlg->Close( true );
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
{
wxFileName fileName = GetBoard()->GetFileName();
@ -518,7 +528,8 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
// want any paint event
Show( false );
Destroy();
// Close frame:
Event.Skip();
}