From c816168e42cc68e3c645eaf0b9f49849c867900b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 7 Sep 2021 09:08:44 -0700 Subject: [PATCH] Fix crash when drawing item When drawing before commit, the items do not have a board and therefore no BDS. In these cases, take a decent default until committed --- pcbnew/pcb_painter.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 362bdbfb9b..33a6dc7ca4 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -464,9 +464,17 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) if( !item ) return false; - BOARD_DESIGN_SETTINGS& bds = item->GetBoard()->GetDesignSettings(); - m_maxError = bds.m_MaxError; - m_holePlatingThickness = bds.GetHolePlatingThickness(); + if( const BOARD* board = item->GetBoard() ) + { + BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); + m_maxError = bds.m_MaxError; + m_holePlatingThickness = bds.GetHolePlatingThickness(); + } + else + { + m_maxError = ARC_HIGH_DEF; + m_holePlatingThickness = 0; + } // the "cast" applied in here clarifies which overloaded draw() is called switch( item->Type() )