PANEL_SETUP_SEVERITIES::ImportSettingsFrom(): fix crash: ensure the option

actually exists before setting it.
Fixes #15525
https://gitlab.com/kicad/code/kicad/-/issues/15525
This commit is contained in:
jean-pierre charras 2023-08-28 18:18:45 +02:00
parent f12c3bb6ff
commit 7ac3e09a08
1 changed files with 8 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 )