From 73193196d26f859cba9e5c15618f5b2d0b62f5e3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 6 Aug 2021 20:22:03 +0200 Subject: [PATCH] Cvpcb: fix possible crash when pressing the ESC key during some calculations. From master branch, commit b1c67d9 --- cvpcb/cvpcb_mainframe.cpp | 9 +++++++++ cvpcb/cvpcb_mainframe.h | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index af735059b1..a5a9e8cd0a 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -125,6 +125,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : m_libListBox = NULL; m_mainToolBar = NULL; m_modified = false; + m_cannotClose = false; m_skipComponentSelect = false; m_filteringOptions = 0; m_tcFilterString = NULL; @@ -307,6 +308,10 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) // clear highlight symbol in schematic: SendMessageToEESCHEMA( true ); + + if( m_cannotClose ) + return; + // Delete window Destroy(); } @@ -1117,7 +1122,11 @@ void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) switch( mail.Command() ) { case MAIL_EESCHEMA_NETLIST: + // Disable Close events during ReadNetListAndFpFiles() to avoid crash when updating + // widgets: + m_cannotClose = true; ReadNetListAndFpFiles( payload ); + m_cannotClose = false; /* @todo Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down. */ diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 1cb86b28c6..04c46ce143 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -80,11 +80,13 @@ public: protected: bool m_modified; - bool m_skipComponentSelect; // true to skip OnSelectComponent event - // (in automatic selection/deletion of associations) + bool m_skipComponentSelect; // true to skip OnSelectComponent event + // (in automatic selection/deletion of associations) PARAM_CFG_ARRAY m_projectFileParams; bool m_initialized; + bool m_cannotClose; // true when the cvpcb frame cannot be closed + // (mainly during reading a netlist sent by Eeschema) CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );