Fix crash bug when highlighting no net (found by Coverity).

This commit is contained in:
Jeff Young 2020-04-12 11:18:40 +01:00
parent bdada70ee7
commit c82679a6f2
1 changed files with 7 additions and 4 deletions

View File

@ -714,10 +714,13 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) ); SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
SCH_COMPONENT* comp = nullptr; SCH_COMPONENT* comp = nullptr;
if( item->Type() == SCH_FIELD_T ) if( item )
comp = dynamic_cast<SCH_COMPONENT*>( item->GetParent() ); {
else if( item->Type() == SCH_FIELD_T )
comp = dynamic_cast<SCH_COMPONENT*>( item ); comp = dynamic_cast<SCH_COMPONENT*>( item->GetParent() );
else
comp = dynamic_cast<SCH_COMPONENT*>( item );
}
if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() ) if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
netName = comp->GetPartRef()->GetName(); netName = comp->GetPartRef()->GetName();