diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 8c19f18f15..05863e1ce7 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -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. } diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index fc66c1d609..10cd5822de 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -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(); } diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index ac16bde787..bbef9dcc55 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -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; diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index 9b8218e0b8..c1dbc4d38b 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -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 { diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index a515bbbdae..be839a3cf2 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -461,8 +461,8 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) Clear_Pcb( false ); - //close the editor - Destroy(); + // Close the editor + Event.Skip(); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index cf348ecbf6..a6e67b8653 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -85,6 +85,7 @@ #include #include #include +#include // for DIALOG_DRC_WINDOW_NAME definition #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) #include @@ -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( + 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(); }