From d49562a7aa598f66ff5cbc9ab8c27f4f46b43fa1 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Wed, 22 Mar 2023 18:39:08 -0400 Subject: [PATCH] Fix crash editing footprint editor defaults Missing one level of GetParent()....use a dynamic_cast to sanity check it in debug Fixes sentry crash KICAD-R4 --- pcbnew/dialogs/panel_fp_editor_defaults.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_defaults.cpp index f7c2be3df4..502f15b43d 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_defaults.cpp @@ -174,7 +174,8 @@ PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider ) : PANEL_FP_EDITOR_DEFAULTS_BASE( aParent ) { - m_parent = static_cast( aParent->GetParent() ); + m_parent = dynamic_cast( aParent->GetParent()->GetParent() ); + wxASSERT_MSG( m_parent, wxS( "Incorrect parent window passed" ) ); m_textItemsGrid->SetDefaultRowSize( m_textItemsGrid->GetDefaultRowSize() + 4 ); @@ -331,7 +332,9 @@ bool PANEL_FP_EDITOR_DEFAULTS::validateData() int textSize = std::min( m_graphicsGrid->GetUnitValue( row, COL_TEXT_WIDTH ), m_graphicsGrid->GetUnitValue( row, COL_TEXT_HEIGHT ) ); - if( m_graphicsGrid->GetUnitValue( row, COL_TEXT_THICKNESS ) > textSize / 4 ) + int thickness = m_graphicsGrid->GetUnitValue( row, COL_TEXT_THICKNESS ); + + if( thickness > textSize / 4 ) { wxString msg = _( "Text will not be readable with a thickness greater than\n" "1/4 its width or height." );