From 1bcc819eed4547fe31450dd93643d179efe881ea Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 1 Aug 2020 20:23:18 +0200 Subject: [PATCH] PANEL_COLOR_SETTINGS: avoid crash if the selected theme is no longer existing. If a previously selected color theme is no longer existing, switch to the default theme to build the panel. Fixes #5032 https://gitlab.com/kicad/code/kicad/issues/5032 --- common/dialogs/panel_color_settings.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp index aa410bc270..2112dd84fd 100644 --- a/common/dialogs/panel_color_settings.cpp +++ b/common/dialogs/panel_color_settings.cpp @@ -198,8 +198,17 @@ void PANEL_COLOR_SETTINGS::createSwatch( int aLayer, const wxString& aName ) { wxStaticText* label = new wxStaticText( m_colorsListWindow, wxID_ANY, aName ); + // The previously selected theme can be deleted and cannot be selected. + // so select the default theme (first theme of the list) + if( m_cbTheme->GetSelection() < 0 ) + { + m_cbTheme->SetSelection( 0 ); + onNewThemeSelected(); + } + void* clientData = m_cbTheme->GetClientData( m_cbTheme->GetSelection() ); COLOR_SETTINGS* selected = static_cast( clientData ); + int id = FIRST_BUTTON_ID + aLayer; COLOR4D defaultColor = selected->GetDefaultColor( aLayer ); COLOR4D color = m_currentSettings->GetColor( aLayer );