Cvpcb: fix possible crash when pressing the ESC key during some calculations, round 2.

It happened when firing a Close Event during calculations modifying widgets
inside the main frame.
The close event is now vetoed during these critical calculations.
This commit is contained in:
jean-pierre charras 2021-08-06 13:40:30 +02:00
parent 89f124595c
commit b1c67d9ad4
2 changed files with 15 additions and 7 deletions

View File

@ -59,7 +59,6 @@
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" ) #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition, KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME ) wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
@ -69,6 +68,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_librariesListBox = nullptr; m_librariesListBox = nullptr;
m_mainToolBar = nullptr; m_mainToolBar = nullptr;
m_modified = false; m_modified = false;
m_cannotClose = false;
m_skipComponentSelect = false; m_skipComponentSelect = false;
m_filteringOptions = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST; m_filteringOptions = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST;
m_tcFilterString = nullptr; m_tcFilterString = nullptr;
@ -394,6 +394,9 @@ bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
} }
} }
if( m_cannotClose )
return false;
return true; return true;
} }
@ -1127,7 +1130,11 @@ void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
switch( mail.Command() ) switch( mail.Command() )
{ {
case MAIL_EESCHEMA_NETLIST: case MAIL_EESCHEMA_NETLIST:
// Disable Close events during ReadNetListAndFpFiles() to avoid crash when updating
// widgets:
m_cannotClose = true;
ReadNetListAndFpFiles( payload ); ReadNetListAndFpFiles( payload );
m_cannotClose = false;
/* @todo /* @todo
Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down. Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
*/ */

View File

@ -367,15 +367,16 @@ private:
void refreshAfterSymbolSearch( COMPONENT* aSymbol ); void refreshAfterSymbolSearch( COMPONENT* aSymbol );
public: public:
FOOTPRINT_LIST* m_FootprintsList; FOOTPRINT_LIST* m_FootprintsList;
protected: protected:
bool m_modified; bool m_modified;
bool m_skipComponentSelect; // skip component selection event during bool m_skipComponentSelect; // skip component selection event during
// automatic selection/deletion of // automatic selection/deletion of associations
// associations
bool m_initialized; bool m_initialized; // true after creating widgets.
bool m_cannotClose; // true when the cvpcb frame cannot be closed
// (mainly during reading a netlist sent by Eeschema)
private: private:
friend struct CV::IFACE; friend struct CV::IFACE;