Prevent dereferencing frame on exit

Processing a menu event for quitting results in the frame being
destroyed.  This crashes the program when it tries to access the newly
freed frame to check for autosave data.  We bind the closing flag into
the base program which will be the last item freed on exit to ensure we
can correctly check for data loss

Fixes https://gitlab.com/kicad/code/kicad/issues/8638
This commit is contained in:
Seth Hillbrand 2021-11-15 10:04:44 -08:00
parent 97943e0c7c
commit f950d96324
4 changed files with 8 additions and 0 deletions

View File

@ -273,6 +273,9 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
if( !wxFrame::ProcessEvent( aEvent ) )
return false;
if( Pgm().m_Quitting )
return true;
if( !m_isClosing && m_hasAutoSave && IsShown() && IsActive()
&& m_autoSaveState != isAutoSaveRequired()
&& m_autoSaveInterval > 0 )

View File

@ -108,6 +108,7 @@ PGM_BASE::PGM_BASE()
{
m_locale = nullptr;
m_Printing = false;
m_Quitting = false;
m_ModalDialogCount = 0;
setLanguageId( wxLANGUAGE_DEFAULT );

View File

@ -292,6 +292,8 @@ public:
int m_ModalDialogCount;
bool m_Quitting;
protected:
/// Loads internal settings from COMMON_SETTINGS
void loadCommonSettings();

View File

@ -435,6 +435,8 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
m_leftWin->EmptyTreePrj();
Pgm().m_Quitting = true;
return true;
}