From bafb06c8c033c0d57c2194a739f234d582c8b0be Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 24 Oct 2015 19:46:50 +0200 Subject: [PATCH] Footprint wizard frame: closing the messages box before closing the frame is no more allowed, to avoid a pcbnew crash when changing a parameter or closing the wizard frame. --- pcbnew/footprint_wizard_frame.cpp | 20 +++++++++++++++++++- pcbnew/footprint_wizard_frame.h | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 1b398dfede..81f2640e2a 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -203,7 +203,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal; // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the // Event Loop Manager, and stop the one created by the dialog. - // It does not happen on all W.M., perhaps due to the way or the order events are called + // It does not happen on all W.M., perhaps due to the way the order events are called // SelectFootprintWizard(); } @@ -637,6 +637,7 @@ FOOTPRINT_WIZARD_MESSAGES::FOOTPRINT_WIZARD_MESSAGES( FOOTPRINT_WIZARD_FRAME* aP wxDefaultPosition, wxDefaultSize, wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT ) { + m_canClose = false; wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL ); SetSizer( bSizer ); @@ -662,6 +663,21 @@ FOOTPRINT_WIZARD_MESSAGES::~FOOTPRINT_WIZARD_MESSAGES() { } + +BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_MESSAGES, wxMiniFrame ) + EVT_CLOSE( FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow ) +END_EVENT_TABLE() + + +void FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow( wxCloseEvent& aEvent ) +{ + if( !m_canClose ) + aEvent.Veto(); + else + aEvent.Skip(); +} + + void FOOTPRINT_WIZARD_MESSAGES::PrintMessage( const wxString& aMessage ) { m_messageWindow->SetValue( aMessage ); @@ -691,6 +707,8 @@ void FOOTPRINT_WIZARD_MESSAGES::SaveSettings() m_config->Write( MESSAGE_BOX_POSY_KEY, m_position.y ); m_config->Write( MESSAGE_BOX_SIZEX_KEY, m_size.x ); m_config->Write( MESSAGE_BOX_SIZEY_KEY, m_size.y ); + + m_canClose = false; // close event now allowed } diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index 05ae6d4983..a8ca4cb1d4 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -220,6 +220,11 @@ private: wxPoint m_position; wxSize m_size; wxConfigBase* m_config; + bool m_canClose; // false to veto a close event, true to allow it + + void OnCloseMsgWindow( wxCloseEvent& aEvent ); + + DECLARE_EVENT_TABLE() }; #endif // FOOTPRINT_WIZARD_FRM_H_