From 2e3d781bf2cbd1f75cf4117e88fe132d7d00085c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 26 Sep 2019 20:48:28 +0200 Subject: [PATCH] layer stack manager: fix a crash due to a recent change in code. --- .../panel_board_stackup.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index 4cb80c59bf..05a126c139 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -1046,11 +1046,23 @@ void PANEL_SETUP_BOARD_STACKUP::onMaterialChange( wxCommandEvent& event ) textCtrl = static_cast( m_rowUiItemsList[row].m_MaterialCtrl ); textCtrl->SetValue( item->m_Material ); - textCtrl = static_cast( m_rowUiItemsList[row].m_EpsilonCtrl ); - textCtrl->SetValue( item->FormatEpsilonR() ); + // some layers have a material choice but not EpsilonR ctrl + if( item->HasEpsilonRValue() ) + { + textCtrl = dynamic_cast( m_rowUiItemsList[row].m_EpsilonCtrl ); - textCtrl = static_cast( m_rowUiItemsList[row].m_LossTgCtrl ); - textCtrl->SetValue( item->FormatLossTangent() ); + if( textCtrl ) + textCtrl->SetValue( item->FormatEpsilonR() ); + } + + // some layers have a material choice but not loss tg ctrl + if( item->HasLossTangentValue() ) + { + textCtrl = dynamic_cast( m_rowUiItemsList[row].m_LossTgCtrl ); + + if( textCtrl ) + textCtrl->SetValue( item->FormatLossTangent() ); + } }