From 967587adcc324b449269b28e1f12234df0cc7302 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 19 Jul 2020 01:47:03 +0100 Subject: [PATCH] Guard against dynamic cast failure --- .../panel_board_stackup.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index 4e9870d4d6..5b59770585 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -1006,16 +1006,20 @@ bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup() const FAB_LAYER_COLOR* color_list = GetColorStandardList(); wxBitmapComboBox* choice = dynamic_cast( ui_item.m_ColorCtrl ); - int idx = choice->GetSelection(); - if( idx == GetColorUserDefinedListIdx() ) + if( choice ) { - wxASSERT( m_UserColors.count( row ) ); - wxColour color = m_UserColors[row]; - item->SetColor( color.GetAsString( wxC2S_HTML_SYNTAX ) ); + int idx = choice->GetSelection(); + + if( idx == GetColorUserDefinedListIdx() ) + { + wxASSERT( m_UserColors.count( row ) ); + wxColour color = m_UserColors[row]; + item->SetColor( color.GetAsString( wxC2S_HTML_SYNTAX ) ); + } + else + item->SetColor( color_list[idx].m_ColorName ); } - else - item->SetColor( color_list[idx].m_ColorName ); } row++;