From f9b59b4fdf2ce353f2d368eabf34f1924dd786e4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 28 Aug 2023 18:18:45 +0200 Subject: [PATCH] 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. --- common/dialogs/panel_setup_severities.cpp | 14 ++++++++------ eeschema/dialogs/dialog_schematic_setup.cpp | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/dialogs/panel_setup_severities.cpp b/common/dialogs/panel_setup_severities.cpp index 6bdc4bd6e5..39b48913cc 100644 --- a/common/dialogs/panel_setup_severities.cpp +++ b/common/dialogs/panel_setup_severities.cpp @@ -161,16 +161,18 @@ void PANEL_SETUP_SEVERITIES::ImportSettingsFrom( std::map& aSetti { int errorCode = item.GetErrorCode(); - if(! m_buttonMap[ errorCode ][0] ) // this entry does not actually exist - continue; + wxRadioButton* button = nullptr; switch( aSettings[ errorCode ] ) { - case RPT_SEVERITY_ERROR: m_buttonMap[ errorCode ][0]->SetValue( true ); break; - case RPT_SEVERITY_WARNING: m_buttonMap[ errorCode ][1]->SetValue( true ); break; - case RPT_SEVERITY_IGNORE: m_buttonMap[ errorCode ][2]->SetValue( true ); break; - default: break; + case RPT_SEVERITY_ERROR: button = m_buttonMap[ errorCode ][0]; break; + case RPT_SEVERITY_WARNING: button = m_buttonMap[ errorCode ][1]; break; + case RPT_SEVERITY_IGNORE: button = m_buttonMap[ errorCode ][2]; break; + default: break; } + + if( button ) // this entry must actually exist + button->SetValue( true ); } if( m_pinMapSpecialCase ) diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp index 3fabd75c7e..5680ac6ebc 100644 --- a/eeschema/dialogs/dialog_schematic_setup.cpp +++ b/eeschema/dialogs/dialog_schematic_setup.cpp @@ -67,6 +67,8 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : }, _( "Field Name Templates" ) ); m_treebook->AddPage( new wxPanel( GetTreebook() ), _( "Electrical Rules" ) ); + + m_severitiesPage = m_treebook->GetPageCount(); m_treebook->AddLazySubPage( [this]( wxWindow* aParent ) -> wxWindow* {