Browse Source

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
pull/16/head
jean-pierre charras 5 years ago
parent
commit
1bcc819eed
  1. 9
      common/dialogs/panel_color_settings.cpp

9
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<COLOR_SETTINGS*>( clientData );
int id = FIRST_BUTTON_ID + aLayer;
COLOR4D defaultColor = selected->GetDefaultColor( aLayer );
COLOR4D color = m_currentSettings->GetColor( aLayer );

Loading…
Cancel
Save