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.

This commit is contained in:
jean-pierre charras 2015-10-24 19:46:50 +02:00
parent a0f52db1c8
commit bafb06c8c0
2 changed files with 24 additions and 1 deletions

View File

@ -203,7 +203,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
// Reason: the FOOTPRINT_WIZARD_FRAME is run as modal; // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
// It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
// Event Loop Manager, and stop the one created by the dialog. // 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(); // SelectFootprintWizard();
} }
@ -637,6 +637,7 @@ FOOTPRINT_WIZARD_MESSAGES::FOOTPRINT_WIZARD_MESSAGES( FOOTPRINT_WIZARD_FRAME* aP
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT ) wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT )
{ {
m_canClose = false;
wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( bSizer ); 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 ) void FOOTPRINT_WIZARD_MESSAGES::PrintMessage( const wxString& aMessage )
{ {
m_messageWindow->SetValue( 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_POSY_KEY, m_position.y );
m_config->Write( MESSAGE_BOX_SIZEX_KEY, m_size.x ); m_config->Write( MESSAGE_BOX_SIZEX_KEY, m_size.x );
m_config->Write( MESSAGE_BOX_SIZEY_KEY, m_size.y ); m_config->Write( MESSAGE_BOX_SIZEY_KEY, m_size.y );
m_canClose = false; // close event now allowed
} }

View File

@ -220,6 +220,11 @@ private:
wxPoint m_position; wxPoint m_position;
wxSize m_size; wxSize m_size;
wxConfigBase* m_config; 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_ #endif // FOOTPRINT_WIZARD_FRM_H_