From 92011d91d2ff6fd97b6a6cf813e3b4a6dcf1b649 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 17 Oct 2019 21:29:26 -0700 Subject: [PATCH] eeschema: Testing for static/dynamic cast failure --- eeschema/tools/sch_edit_tool.cpp | 3 +++ eeschema/tools/sch_line_wire_bus_tool.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 59ff39fab8..c512240a1a 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -902,6 +902,9 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) { SCH_ITEM* sch_item = dynamic_cast( item ); + if( !sch_item ) + continue; + if( sch_item->Type() == SCH_JUNCTION_T ) { sch_item->SetFlags( STRUCT_DELETED ); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index f0f49f5a93..dc1a5d737b 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -866,10 +866,10 @@ int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( const TOOL_EVENT& aEvent ) for( unsigned ii = 0; ii < aSelection->GetSize(); ii++ ) { - SCH_ITEM* item = static_cast( aSelection->GetItem( ii ) ); + SCH_ITEM* item = dynamic_cast( aSelection->GetItem( ii ) ); std::vector new_pts; - if( !item->IsConnectable() ) + if( !item || !item->IsConnectable() ) continue; item->GetConnectionPoints( new_pts );