Avoid using a nullptr.

This commit is contained in:
jean-pierre charras 2024-03-20 18:34:18 +01:00
parent 350687f355
commit 8bdc62c111
1 changed files with 11 additions and 7 deletions

View File

@ -1888,8 +1888,11 @@ void PNS_KICAD_IFACE_BASE::AddItem( PNS::ITEM* aItem )
BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem ) BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
{ {
BOARD_CONNECTED_ITEM* newBI = nullptr; BOARD_CONNECTED_ITEM* newBoardItem = nullptr;
auto net = static_cast<NETINFO_ITEM*>( aItem->Net() ); NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( aItem->Net() );
if( !net )
net = NETINFO_LIST::OrphanedItem();
switch( aItem->Kind() ) switch( aItem->Kind() )
{ {
@ -1900,7 +1903,7 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
new_arc->SetWidth( arc->Width() ); new_arc->SetWidth( arc->Width() );
new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) ); new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
new_arc->SetNet( net ); new_arc->SetNet( net );
newBI = new_arc; newBoardItem = new_arc;
break; break;
} }
@ -1914,7 +1917,7 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
track->SetWidth( seg->Width() ); track->SetWidth( seg->Width() );
track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) ); track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
track->SetNet( net ); track->SetNet( net );
newBI = track; newBoardItem = track;
break; break;
} }
@ -1930,7 +1933,7 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
via_board->SetIsFree( via->IsFree() ); via_board->SetIsFree( via->IsFree() );
via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ), via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
ToLAYER_ID( via->Layers().End() ) ); ToLAYER_ID( via->Layers().End() ) );
newBI = via_board; newBoardItem = via_board;
break; break;
} }
@ -1949,12 +1952,13 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
if( net->GetNetCode() <= 0 ) if( net->GetNetCode() <= 0 )
{ {
NETINFO_ITEM* newNetInfo = newBI->GetNet(); NETINFO_ITEM* newNetInfo = newBoardItem->GetNet();
newNetInfo->SetParent( m_board ); newNetInfo->SetParent( m_board );
newNetInfo->SetNetClass( m_board->GetDesignSettings().m_NetSettings->m_DefaultNetClass ); newNetInfo->SetNetClass( m_board->GetDesignSettings().m_NetSettings->m_DefaultNetClass );
} }
return newBI; return newBoardItem;
} }