PANEL_SETUP_SEVERITIES: fix a missing init (m_severitiesPage) creating a crash.

PANEL_SETUP_SEVERITIES::ImportSettingsFrom(): ensure the option to set
actually exists before setting it.
This commit is contained in:
jean-pierre charras 2023-08-28 18:18:45 +02:00
parent 76a3b3db97
commit f9b59b4fdf
2 changed files with 10 additions and 6 deletions

View File

@ -161,16 +161,18 @@ void PANEL_SETUP_SEVERITIES::ImportSettingsFrom( std::map<int, SEVERITY>& aSetti
{ {
int errorCode = item.GetErrorCode(); int errorCode = item.GetErrorCode();
if(! m_buttonMap[ errorCode ][0] ) // this entry does not actually exist wxRadioButton* button = nullptr;
continue;
switch( aSettings[ errorCode ] ) switch( aSettings[ errorCode ] )
{ {
case RPT_SEVERITY_ERROR: m_buttonMap[ errorCode ][0]->SetValue( true ); break; case RPT_SEVERITY_ERROR: button = m_buttonMap[ errorCode ][0]; break;
case RPT_SEVERITY_WARNING: m_buttonMap[ errorCode ][1]->SetValue( true ); break; case RPT_SEVERITY_WARNING: button = m_buttonMap[ errorCode ][1]; break;
case RPT_SEVERITY_IGNORE: m_buttonMap[ errorCode ][2]->SetValue( true ); break; case RPT_SEVERITY_IGNORE: button = m_buttonMap[ errorCode ][2]; break;
default: break; default: break;
} }
if( button ) // this entry must actually exist
button->SetValue( true );
} }
if( m_pinMapSpecialCase ) if( m_pinMapSpecialCase )

View File

@ -67,6 +67,8 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
}, _( "Field Name Templates" ) ); }, _( "Field Name Templates" ) );
m_treebook->AddPage( new wxPanel( GetTreebook() ), _( "Electrical Rules" ) ); m_treebook->AddPage( new wxPanel( GetTreebook() ), _( "Electrical Rules" ) );
m_severitiesPage = m_treebook->GetPageCount();
m_treebook->AddLazySubPage( m_treebook->AddLazySubPage(
[this]( wxWindow* aParent ) -> wxWindow* [this]( wxWindow* aParent ) -> wxWindow*
{ {