PCB_VIEW: Fix a few ASAN issues

This commit is contained in:
Jon Evans 2020-12-29 12:08:23 -05:00
parent 50b171fa33
commit 76e8c62269
2 changed files with 15 additions and 15 deletions

View File

@ -41,6 +41,7 @@
using namespace KIGFX;
VIEW_GROUP::VIEW_GROUP( VIEW* aView ) :
VIEW_ITEM(),
m_layer( LAYER_SELECT_OVERLAY )
{
}

View File

@ -58,55 +58,54 @@ PCB_VIEW::~PCB_VIEW()
void PCB_VIEW::Add( KIGFX::VIEW_ITEM* aItem, int aDrawPriority )
{
auto item = static_cast<BOARD_ITEM*>( aItem );
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( aItem );
if( item->Type() == PCB_FOOTPRINT_T )
if( boardItem && boardItem->Type() == PCB_FOOTPRINT_T )
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
footprint->RunOnChildren( [this]( BOARD_ITEM* aChild )
{
VIEW::Add( aChild );
} );
}
VIEW::Add( item, aDrawPriority );
VIEW::Add( aItem, aDrawPriority );
}
void PCB_VIEW::Remove( KIGFX::VIEW_ITEM* aItem )
{
auto item = static_cast<BOARD_ITEM*>( aItem );
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( aItem );
if( item->Type() == PCB_FOOTPRINT_T )
if( boardItem && boardItem->Type() == PCB_FOOTPRINT_T )
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
footprint->RunOnChildren( [this]( BOARD_ITEM* aChild )
{
VIEW::Remove( aChild );
} );
}
VIEW::Remove( item );
VIEW::Remove( aItem );
}
void PCB_VIEW::Update( const KIGFX::VIEW_ITEM* aItem, int aUpdateFlags ) const
{
const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( aItem );
const BOARD_ITEM* boardItem = dynamic_cast<const BOARD_ITEM*>( aItem );
if( item->Type() == PCB_FOOTPRINT_T )
if( boardItem && boardItem->Type() == PCB_FOOTPRINT_T )
{
const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( item );
const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( boardItem );
footprint->RunOnChildren(
[this, aUpdateFlags]( BOARD_ITEM* aModItem )
{
VIEW::Update( aModItem, aUpdateFlags );
} );
}
else if( item->Type() == PCB_GROUP_T )
else if( boardItem && boardItem->Type() == PCB_GROUP_T )
{
const PCB_GROUP* group = static_cast<const PCB_GROUP*>( item );
const PCB_GROUP* group = static_cast<const PCB_GROUP*>( boardItem );
group->RunOnChildren(
[this, aUpdateFlags]( BOARD_ITEM* aModItem )
{
@ -114,7 +113,7 @@ void PCB_VIEW::Update( const KIGFX::VIEW_ITEM* aItem, int aUpdateFlags ) const
} );
}
VIEW::Update( item, aUpdateFlags );
VIEW::Update( aItem, aUpdateFlags );
}