Small improvements to lifecycle safety.

Fixes https://gitlab.com/kicad/code/kicad/issues/14521

Fixes https://gitlab.com/kicad/code/kicad/issues/14315

(cherry picked from commit cc4a8dcc89)
This commit is contained in:
Jeff Young 2023-04-16 18:45:17 +01:00
parent 5cc1e2e42d
commit 518980d9ed
1 changed files with 16 additions and 29 deletions

View File

@ -27,6 +27,7 @@
#include <bitmaps.h>
#include <confirm.h>
#include <core/arraydim.h>
#include <core/kicad_algo.h>
#include <dialog_shim.h>
#include <eda_draw_frame.h>
#include <file_history.h>
@ -741,21 +742,21 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
int aPadding )
{
if( m_messagePanel )
if( m_messagePanel && !m_isClosing )
m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
}
void EDA_DRAW_FRAME::ClearMsgPanel()
{
if( m_messagePanel )
if( m_messagePanel && !m_isClosing )
m_messagePanel->EraseMsgBox();
}
void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
{
if( m_messagePanel )
if( m_messagePanel && !m_isClosing )
{
m_messagePanel->EraseMsgBox();
@ -768,10 +769,9 @@ void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
void EDA_DRAW_FRAME::SetMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
int aPadding )
{
if( m_messagePanel )
if( m_messagePanel && !m_isClosing )
{
m_messagePanel->EraseMsgBox();
m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
}
}
@ -842,7 +842,7 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
// Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
// have a fixed type, or do not have a option to set the canvas type (they inherit from
// a parent frame)
FRAME_T allowed_frames[] =
static std::vector<FRAME_T> s_allowedFrames =
{
FRAME_SCH, FRAME_SCH_SYMBOL_EDITOR,
FRAME_PCB_EDITOR, FRAME_FOOTPRINT_EDITOR,
@ -850,18 +850,7 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
FRAME_PL_EDITOR
};
bool allow_save = false;
for( unsigned ii = 0; ii < arrayDim( allowed_frames ); ii++ )
{
if( m_ident == allowed_frames[ii] )
{
allow_save = true;
break;
}
}
if( !allow_save )
if( !alg::contains( s_allowedFrames, m_ident ) )
return false;
if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
@ -871,9 +860,7 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
return false;
}
APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
if( cfg )
if( APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings() )
cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
return false;